diff --git a/src/canonicalize_and_process.rs b/src/canonicalize_and_process.rs index c172306..7957589 100644 --- a/src/canonicalize_and_process.rs +++ b/src/canonicalize_and_process.rs @@ -53,10 +53,8 @@ pub fn canonicalize_port( } } -// Ref: https://wicg.github.io/urlpattern/#canonicalize-a-standard-pathname -pub fn canonicalize_standard_pathname( - value: &str, -) -> Result { +// Ref: https://wicg.github.io/urlpattern/#canonicalize-a-pathname +pub fn canonicalize_pathname(value: &str) -> Result { let mut url = url::Url::parse("http://dummy.test").unwrap(); url.set_path(value); Ok(url::quirks::pathname(&url).to_string()) @@ -168,7 +166,7 @@ pub fn process_pathname_init( } else { match protocol_value { Some(protocol) if is_special_scheme(protocol) => { - canonicalize_standard_pathname(pathname_value) + canonicalize_pathname(pathname_value) } _ => canonicalize_cannot_be_a_base_url_pathname(pathname_value), } diff --git a/src/constructor_parser.rs b/src/constructor_parser.rs index f0c3d35..96511cc 100644 --- a/src/constructor_parser.rs +++ b/src/constructor_parser.rs @@ -30,7 +30,7 @@ struct ConstructorStringParser<'a> { token_index: usize, token_increment: usize, group_depth: usize, - should_treat_as_standard_url: bool, + protocol_matches_special_scheme: bool, state: ConstructorStringParserState, } @@ -194,8 +194,10 @@ impl<'a> ConstructorStringParser<'a> { self.token_list[self.token_index].kind == TokenType::Close } - // Ref: https://wicg.github.io/urlpattern/#compute-should-treat-as-a-standard-url - fn compute_should_treat_as_standard_url(&mut self) -> Result<(), ParseError> { + // Ref: https://wicg.github.io/urlpattern/#compute-protocol-matches-a-special-scheme-flag + fn compute_protocol_matches_special_scheme( + &mut self, + ) -> Result<(), ParseError> { let protocol_string = self.make_component_string(); let protocol_component = crate::component::Component::compile( &protocol_string, @@ -203,7 +205,7 @@ impl<'a> ConstructorStringParser<'a> { Default::default(), )?; if protocol_component.protocol_component_matches_special_scheme() { - self.should_treat_as_standard_url = true; + self.protocol_matches_special_scheme = true; } Ok(()) } @@ -244,7 +246,7 @@ pub fn parse_constructor_string( token_index: 0, token_increment: 1, group_depth: 0, - should_treat_as_standard_url: false, + protocol_matches_special_scheme: false, state: ConstructorStringParserState::Init, }; @@ -302,8 +304,8 @@ pub fn parse_constructor_string( } ConstructorStringParserState::Protocol => { if parser.is_protocol_suffix() { - parser.compute_should_treat_as_standard_url()?; - if parser.should_treat_as_standard_url { + parser.compute_protocol_matches_special_scheme()?; + if parser.protocol_matches_special_scheme { parser.result.pathname = Some(String::from("/")); } let mut next_state = ConstructorStringParserState::Pathname; @@ -311,7 +313,7 @@ pub fn parse_constructor_string( if parser.next_is_authority_slashes() { next_state = ConstructorStringParserState::Authority; skip = 3; - } else if parser.should_treat_as_standard_url { + } else if parser.protocol_matches_special_scheme { next_state = ConstructorStringParserState::Authority; } parser.change_state(next_state, skip); diff --git a/src/lib.rs b/src/lib.rs index c44045c..12e8b20 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -270,8 +270,8 @@ impl UrlPattern { let pathname = if protocol.protocol_component_matches_special_scheme() { Component::compile( &processed_init.pathname.unwrap(), - canonicalize_and_process::canonicalize_standard_pathname, - parser::Options::standard_pathname(), + canonicalize_and_process::canonicalize_pathname, + parser::Options::pathname(), )? } else { Component::compile( diff --git a/src/parser.rs b/src/parser.rs index c6a504f..00f7070 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -34,9 +34,9 @@ impl Options { } } - // Ref: https://wicg.github.io/urlpattern/#standard-pathname-options + // Ref: https://wicg.github.io/urlpattern/#pathname-options #[inline] - pub fn standard_pathname() -> Self { + pub fn pathname() -> Self { Options { delimiter_code_point: String::from("/"), prefix_code_point: String::from("/"),