(value: &str)
| 519 | |
| 520 | #[cfg(unix)] |
| 521 | fn percent_encode_query_value(value: &str) -> String { |
| 522 | let mut encoded = String::with_capacity(value.len()); |
| 523 | for byte in value.bytes() { |
| 524 | if matches!( |
| 525 | byte, |
| 526 | b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'.' | b'_' | b'~' | b'/' |
| 527 | ) { |
| 528 | encoded.push(byte as char); |
| 529 | } else { |
| 530 | encoded.push_str(&format!("%{byte:02X}")); |
| 531 | } |
| 532 | } |
| 533 | encoded |
| 534 | } |
| 535 | |
| 536 | #[cfg(all(test, unix))] |
| 537 | mod tests { |