diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 1a21655..5675074 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.92.0" +channel = "1.87.0" components = ["rustfmt", "clippy"] diff --git a/src/lib.rs b/src/lib.rs index 199b23a..3baa9fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -207,16 +207,17 @@ impl UrlPatternInit { if let Some(pathname) = &self.pathname { result.pathname = Some(pathname.clone()); - if let Some(base_url) = base_url - && !base_url.cannot_be_a_base() - && !is_absolute_pathname(pathname, &kind) - { - let baseurl_path = url::quirks::pathname(base_url); - let slash_index = baseurl_path.rfind('/'); - if let Some(slash_index) = slash_index { - let new_pathname = baseurl_path[..=slash_index].to_string(); - result.pathname = - Some(format!("{}{}", new_pathname, result.pathname.unwrap())); + if let Some(base_url) = base_url { + if !base_url.cannot_be_a_base() + && !is_absolute_pathname(pathname, &kind) + { + let baseurl_path = url::quirks::pathname(base_url); + let slash_index = baseurl_path.rfind('/'); + if let Some(slash_index) = slash_index { + let new_pathname = baseurl_path[..=slash_index].to_string(); + result.pathname = + Some(format!("{}{}", new_pathname, result.pathname.unwrap())); + } } } @@ -331,12 +332,12 @@ impl UrlPattern { )?; // If processedInit["protocol"] is a special scheme and processedInit["port"] is its corresponding default port - if let Some(protocol) = &processed_init.protocol - && is_special_scheme(protocol) - { - let default_port = special_scheme_default_port(protocol); - if default_port == processed_init.port.as_deref() { - processed_init.port = Some(String::new()) + if let Some(protocol) = &processed_init.protocol { + if is_special_scheme(protocol) { + let default_port = special_scheme_default_port(protocol); + if default_port == processed_init.port.as_deref() { + processed_init.port = Some(String::new()) + } } } @@ -924,13 +925,13 @@ mod tests { let match_input = quirks::process_match_input(input, base_url.as_deref()); - if let Some(ExpectedMatch::String(s)) = &case.expected_match - && s == "error" - { - assert!(match_input.is_err()); - println!("✅ Passed"); - return; - }; + if let Some(ExpectedMatch::String(s)) = &case.expected_match { + if s == "error" { + assert!(match_input.is_err()); + println!("✅ Passed"); + return; + } + } let input = match_input.expect("failed to parse match input"); @@ -949,14 +950,14 @@ mod tests { } else { Ok(None) }; - if let Some(ExpectedMatch::String(s)) = &case.expected_match - && s == "error" - { - assert!(test_res.is_err()); - assert!(exec_res.is_err()); - println!("✅ Passed"); - return; - }; + if let Some(ExpectedMatch::String(s)) = &case.expected_match { + if s == "error" { + assert!(test_res.is_err()); + assert!(exec_res.is_err()); + println!("✅ Passed"); + return; + } + } let expected_match = case.expected_match.map(|x| match x { ExpectedMatch::String(_) => unreachable!(),