Skip to main content

encode_path_segment

Function encode_path_segment 

Source
pub fn encode_path_segment(input: &str) -> String
Expand description

Percent-encodes a single URL path segment, so that values interpolated into the path (such as key-value-store record keys or request IDs) cannot break out of the segment or inject a query string.

Encodes everything except the RFC 3986 “unreserved” characters. Notably /, ?, #, space and any non-ASCII bytes are escaped — unlike a raw format!(".../{key}"), which would leave them intact and produce a malformed or wrong-endpoint URL.