From 45d6fbb9e25b000d7a1c6ff4837ef0d887852d1e Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Mon, 24 Jun 2024 00:39:41 -0600 Subject: [PATCH] Fix percent encoding When the first digit is 0 --- src/hyperlink.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hyperlink.rs b/src/hyperlink.rs index c8c5bad..d137194 100644 --- a/src/hyperlink.rs +++ b/src/hyperlink.rs @@ -39,7 +39,7 @@ fn encode(f: &mut Formatter, byte: u8) -> fmt::Result { #[cfg(windows)] b'\\' => f.write_char('/'), _ => { - write!(f, "%{:X}", byte) + write!(f, "%{:02X}", byte) } } } @@ -80,8 +80,8 @@ mod test { #[test] fn test_unicode_encoding() { assert_eq!( - Encoded("$*\x1bßé/∫😃").to_string(), - "%24%2A%1B%C3%9F%C3%A9/%E2%88%AB%F0%9F%98%83", + Encoded("$*\x1bßé/∫😃\x07").to_string(), + "%24%2A%1B%C3%9F%C3%A9/%E2%88%AB%F0%9F%98%83%07", ); } }