Skip to content

Commit d3f6a05

Browse files
fix: get codepoint range rather than bytes (#45)
1 parent 6b09f74 commit d3f6a05

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/constructor_parser.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,13 @@ impl<'a> ConstructorStringParser<'a> {
230230
assert!(self.token_index < self.token_list.len());
231231
let token = &self.token_list[self.token_index];
232232
let component_start_index = self.get_safe_token(self.component_start).index;
233+
233234
self
234235
.input
235-
.get(component_start_index..token.index) // TODO: check & codepoint
236-
.unwrap()
237-
.to_string()
236+
.chars()
237+
.skip(component_start_index)
238+
.take(token.index - component_start_index)
239+
.collect()
238240
}
239241

240242
// Ref: https://wicg.github.io/urlpattern/#rewind-and-set-state

src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,15 @@ mod tests {
954954
.unwrap();
955955
}
956956

957+
#[test]
958+
fn issue46() {
959+
quirks::process_construct_pattern_input(
960+
quirks::StringOrInit::String(":café://:foo".to_owned()),
961+
None,
962+
)
963+
.unwrap();
964+
}
965+
957966
#[test]
958967
fn has_regexp_group() {
959968
let pattern = <UrlPattern>::parse(UrlPatternInit {

0 commit comments

Comments
 (0)