Expand description
Percent-encoding with the same rules as Python’s yarl.
quoteencodes a literal value: every character that isn’t allowed in the component, including%, is percent-encoded.requotenormalizes an already-encoded value: valid%XXescapes are kept (uppercased, or decoded when they encode an unreserved character), any other disallowed character is percent-encoded.unquotedecodes a value. Escapes that don’t form valid UTF-8 are kept as is.
All functions borrow the input if it doesn’t need to change.
use urly::quoting::{Component, quote, requote, unquote};
assert_eq!(quote("a b/100%", Component::Path), "a%20b/100%25");
assert_eq!(requote("a b/100%25%7e", Component::Path), "a%20b/100%25~");
assert_eq!(quote("a b&c=d", Component::QueryPart), "a+b%26c%3Dd");
assert_eq!(unquote("a+b%26c", Component::QueryPart), "a b&c");
assert_eq!(quote("a=b; c", Component::Opaque), "a%3Db%3B%20c");Enums§
- Component
- The URL component a value belongs to; it selects the characters that are left unencoded.