Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.5.6"
regex = "1.10.5"
serde = { version = "1.0.127", features = ["derive"] }
unic-ucd-ident = { version = "0.9.0", features = ["id"] }
icu_properties = "2"

[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 @@ -1063,6 +1063,22 @@ mod tests {
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"]
);
}

#[test]
fn issue61() {
// Test case for https://github.com/denoland/deno/issues/29935
Expand Down
13 changes: 11 additions & 2 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

use crate::error::TokenizerError;
use crate::Error;
use icu_properties::{
props::{IdContinue, IdStart},
CodePointSetDataBorrowed,
};

// Ref: https://wicg.github.io/urlpattern/#tokens
// Ref: https://wicg.github.io/urlpattern/#tokenizing
Expand Down Expand Up @@ -323,13 +327,18 @@ pub fn tokenize(
Ok(tokenizer.token_list)
}

static ID_START: CodePointSetDataBorrowed<'_> =
CodePointSetDataBorrowed::new::<IdStart>();
static ID_CONTINUE: CodePointSetDataBorrowed<'_> =
CodePointSetDataBorrowed::new::<IdContinue>();

// Ref: https://wicg.github.io/urlpattern/#is-a-valid-name-code-point
#[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, '$' | '_')
ID_START.contains(code_point) || matches!(code_point, '$' | '_')
} else {
unic_ucd_ident::is_id_continue(code_point)
ID_CONTINUE.contains(code_point)
|| matches!(code_point, '$' | '\u{200C}' | '\u{200D}')
}
}