Skip to content

Commit

Permalink
fix: get codepoint range rather than bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
melbourne2991 committed Jan 16, 2024
1 parent e65cfc9 commit a6b0ecf
Show file tree
Hide file tree
Showing 2 changed files with 13 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 @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,4 +833,12 @@ mod tests {
})
.unwrap();
}

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

0 comments on commit a6b0ecf

Please sign in to comment.