(value: &str)
| 1196 | } |
| 1197 | |
| 1198 | fn 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 | |
| 1222 | fn hex_value(byte: u8) -> Option<u8> { |
| 1223 | match byte { |
no test coverage detected