MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / percent_decode_query_component

Function percent_decode_query_component

packages/server/src/devtools.rs:1198–1220  ·  view source on GitHub ↗
(value: &str)

Source from the content-addressed store, hash-verified

1196}
1197
1198fn percent_decode_query_component(value: &str) -> String {
1199 let mut decoded = Vec::with_capacity(value.len());
1200 let bytes = value.as_bytes();
1201 let mut index = 0;
1202 while index < bytes.len() {
1203 if bytes[index] == b'%' && index + 2 < bytes.len() {
1204 let high = hex_value(bytes[index + 1]);
1205 let low = hex_value(bytes[index + 2]);
1206 if let (Some(high), Some(low)) = (high, low) {
1207 decoded.push((high << 4) | low);
1208 index += 3;
1209 continue;
1210 }
1211 }
1212 if bytes[index] == b'+' {
1213 decoded.push(b' ');
1214 } else {
1215 decoded.push(bytes[index]);
1216 }
1217 index += 1;
1218 }
1219 String::from_utf8_lossy(&decoded).into_owned()
1220}
1221
1222fn hex_value(byte: u8) -> Option<u8> {
1223 match byte {

Callers 1

Calls 1

hex_valueFunction · 0.85

Tested by

no test coverage detected