Skip to content

Commit a6b0ecf

Browse files
committed
fix: get codepoint range rather than bytes
1 parent e65cfc9 commit a6b0ecf

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/constructor_parser.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,13 @@ impl<'a> ConstructorStringParser<'a> {
167167
assert!(self.token_index < self.token_list.len());
168168
let token = &self.token_list[self.token_index];
169169
let component_start_index = self.get_safe_token(self.component_start).index;
170+
170171
self
171172
.input
172-
.get(component_start_index..token.index) // TODO: check & codepoint
173-
.unwrap()
174-
.to_string()
173+
.chars()
174+
.skip(component_start_index)
175+
.take(token.index - component_start_index)
176+
.collect()
175177
}
176178

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

src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -833,4 +833,12 @@ mod tests {
833833
})
834834
.unwrap();
835835
}
836+
837+
#[test]
838+
fn issue46() {
839+
quirks::process_construct_pattern_input(
840+
quirks::StringOrInit::String(":café://:foo".to_owned()),
841+
None,
842+
).unwrap();
843+
}
836844
}

0 commit comments

Comments
 (0)