Skip to content

Commit b047afe

Browse files
authored
chore: use icu_properties instead of unic-ucd-ident (#67)
1 parent 198d4bc commit b047afe

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license = "MIT"
1111
url = "2.5.6"
1212
regex = "1.10.5"
1313
serde = { version = "1.0.127", features = ["derive"] }
14-
unic-ucd-ident = { version = "0.9.0", features = ["id"] }
14+
icu_properties = "2"
1515

1616
[dev-dependencies]
1717
serde_json = "1.0.66"

src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,22 @@ mod tests {
10631063
assert!(pattern.has_regexp_groups());
10641064
}
10651065

1066+
#[test]
1067+
fn issue54() {
1068+
let pattern = <UrlPattern>::parse(
1069+
UrlPatternInit {
1070+
pathname: Some("/:thereisa\u{30FB}middledot.".to_owned()),
1071+
..Default::default()
1072+
},
1073+
Default::default(),
1074+
)
1075+
.unwrap();
1076+
assert_eq!(
1077+
pattern.pathname.group_name_list,
1078+
vec!["thereisa\u{30FB}middledot"]
1079+
);
1080+
}
1081+
10661082
#[test]
10671083
fn issue61() {
10681084
// Test case for https://github.com/denoland/deno/issues/29935

src/tokenizer.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
use crate::error::TokenizerError;
44
use crate::Error;
5+
use icu_properties::{
6+
props::{IdContinue, IdStart},
7+
CodePointSetDataBorrowed,
8+
};
59

610
// Ref: https://wicg.github.io/urlpattern/#tokens
711
// Ref: https://wicg.github.io/urlpattern/#tokenizing
@@ -323,13 +327,18 @@ pub fn tokenize(
323327
Ok(tokenizer.token_list)
324328
}
325329

330+
static ID_START: CodePointSetDataBorrowed<'_> =
331+
CodePointSetDataBorrowed::new::<IdStart>();
332+
static ID_CONTINUE: CodePointSetDataBorrowed<'_> =
333+
CodePointSetDataBorrowed::new::<IdContinue>();
334+
326335
// Ref: https://wicg.github.io/urlpattern/#is-a-valid-name-code-point
327336
#[inline]
328337
pub(crate) fn is_valid_name_codepoint(code_point: char, first: bool) -> bool {
329338
if first {
330-
unic_ucd_ident::is_id_start(code_point) || matches!(code_point, '$' | '_')
339+
ID_START.contains(code_point) || matches!(code_point, '$' | '_')
331340
} else {
332-
unic_ucd_ident::is_id_continue(code_point)
341+
ID_CONTINUE.contains(code_point)
333342
|| matches!(code_point, '$' | '\u{200C}' | '\u{200D}')
334343
}
335344
}

0 commit comments

Comments
 (0)