Skip to content

Commit

Permalink
fix: get codepoint range rather than bytes (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
melbourne2991 authored Jul 26, 2024
1 parent 6b09f74 commit d3f6a05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/constructor_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,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
Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,15 @@ mod tests {
.unwrap();
}

#[test]
fn issue46() {
quirks::process_construct_pattern_input(
quirks::StringOrInit::String(":café://:foo".to_owned()),
None,
)
.unwrap();
}

#[test]
fn has_regexp_group() {
let pattern = <UrlPattern>::parse(UrlPatternInit {
Expand Down

0 comments on commit d3f6a05

Please sign in to comment.