From a6b0ecf01509079fd36382574e28df505d245508 Mon Sep 17 00:00:00 2001 From: Will Leach <4619280+melbourne2991@users.noreply.github.com> Date: Mon, 15 Jan 2024 22:44:55 +1100 Subject: [PATCH 1/2] fix: get codepoint range rather than bytes --- src/constructor_parser.rs | 8 +++++--- src/lib.rs | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/constructor_parser.rs b/src/constructor_parser.rs index 94d9e6b..ebb626a 100644 --- a/src/constructor_parser.rs +++ b/src/constructor_parser.rs @@ -167,11 +167,13 @@ impl<'a> ConstructorStringParser<'a> { assert!(self.token_index < self.token_list.len()); let token = &self.token_list[self.token_index]; let component_start_index = self.get_safe_token(self.component_start).index; + self .input - .get(component_start_index..token.index) // TODO: check & codepoint - .unwrap() - .to_string() + .chars() + .skip(component_start_index) + .take(token.index - component_start_index) + .collect() } // Ref: https://wicg.github.io/urlpattern/#rewind-and-set-state diff --git a/src/lib.rs b/src/lib.rs index ed688cd..8fd9606 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -833,4 +833,12 @@ mod tests { }) .unwrap(); } + + #[test] + fn issue46() { + quirks::process_construct_pattern_input( + quirks::StringOrInit::String(":café://:foo".to_owned()), + None, + ).unwrap(); + } } From 9b63379b982c948e12dc55050421f773a16520c9 Mon Sep 17 00:00:00 2001 From: crowlkats Date: Fri, 26 Jul 2024 21:20:10 +0200 Subject: [PATCH 2/2] fmt --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 92a757d..7e54d47 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -959,7 +959,8 @@ mod tests { quirks::process_construct_pattern_input( quirks::StringOrInit::String(":café://:foo".to_owned()), None, - ).unwrap(); + ) + .unwrap(); } #[test]