Skip to content

Commit

Permalink
chore: use unicode-id-start instead of unic-ucd-ident
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato committed Feb 19, 2025
1 parent 2ba16e7 commit 0598851
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "MIT"
url = "2.4.1"
regex = "1.10.5"
serde = { version = "1.0.127", features = ["derive"] }
unic-ucd-ident = { version = "0.9.0", features = ["id"] }
unicode-id-start = "1"

[dev-dependencies]
serde_json = "1.0.66"
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1047,4 +1047,20 @@ mod tests {
.unwrap();
assert!(pattern.has_regexp_groups());
}

#[test]
fn issue54() {
let pattern = <UrlPattern>::parse(
UrlPatternInit {
pathname: Some("/:thereisa\u{30FB}middledot.".to_owned()),
..Default::default()
},
Default::default(),
)
.unwrap();
assert_eq!(
pattern.pathname.group_name_list,
vec!["thereisa\u{30FB}middledot"]
);
}
}
4 changes: 2 additions & 2 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ pub fn tokenize(
#[inline]
pub(crate) fn is_valid_name_codepoint(code_point: char, first: bool) -> bool {
if first {
unic_ucd_ident::is_id_start(code_point) || matches!(code_point, '$' | '_')
unicode_id_start::is_id_start(code_point) || matches!(code_point, '$' | '_')
} else {
unic_ucd_ident::is_id_continue(code_point)
unicode_id_start::is_id_continue(code_point)
|| matches!(code_point, '$' | '\u{200C}' | '\u{200D}')
}
}

0 comments on commit 0598851

Please sign in to comment.