Minimal percent-encoding for query parameter values. Note: `percent-encoding` is available as a transitive dependency but is not a direct dependency of this crate. Rather than adding a new dep for one call site, we keep this self-contained implementation.
(s: &str)
| 746 | /// a direct dependency of this crate. Rather than adding a new dep for one |
| 747 | /// call site, we keep this self-contained implementation. |
| 748 | fn url_encode(s: &str) -> String { |
| 749 | s.bytes() |
| 750 | .map(|b| match b { |
| 751 | b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => { |
| 752 | String::from(b as char) |
| 753 | } |
| 754 | _ => format!("%{b:02X}"), |
| 755 | }) |
| 756 | .collect() |
| 757 | } |
| 758 | |
| 759 | #[cfg(test)] |
| 760 | mod tests { |
no outgoing calls
no test coverage detected