MCPcopy Create free account
hub / github.com/RizeCrime/linuxblaster_control / url_decode

Function url_decode

build.rs:17–37  ·  view source on GitHub ↗
(s: &str)

Source from the content-addressed store, hash-verified

15}
16
17fn url_decode(s: &str) -> String {
18 let mut out = Vec::new();
19 let bytes = s.as_bytes();
20 let mut i = 0;
21 while i < bytes.len() {
22 if bytes[i] == b'%'
23 && i + 2 < bytes.len()
24 && let Ok(byte) = u8::from_str_radix(
25 std::str::from_utf8(&bytes[i + 1..i + 3]).unwrap(),
26 16,
27 )
28 {
29 out.push(byte);
30 i += 3;
31 continue;
32 }
33 out.push(bytes[i]);
34 i += 1;
35 }
36 String::from_utf8_lossy(&out).to_string()
37}
38
39fn main() {
40 println!("cargo:rerun-if-changed=build.rs");

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected