diff options
Diffstat (limited to 'cache/src/helper.rs')
| -rw-r--r-- | cache/src/helper.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/cache/src/helper.rs b/cache/src/helper.rs index 8f73e1e..46ef661 100644 --- a/cache/src/helper.rs +++ b/cache/src/helper.rs @@ -31,16 +31,22 @@ impl<T: Hash> Display for HashKey<T> { } } +const SAFE_CHARS: percent_encoding::AsciiSet = percent_encoding::CONTROLS + .add(b'.') + .add(b'%') + .add(b'/') + .add(b'#') + .add(b'?') + .add(b'@'); + pub struct EscapeKey<T>(pub T); impl<T: Display> Display for EscapeKey<T> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "{}", - percent_encoding::utf8_percent_encode( - &self.0.to_string(), - percent_encoding::NON_ALPHANUMERIC, - ) + // TODO perf + f.write_str( + &percent_encoding::utf8_percent_encode(&self.0.to_string(), &SAFE_CHARS) + .to_string() + .replace("%", "@"), ) } } |