Skip to content

Commit f58e042

Browse files
authored
make the crate 1.87.0 compliant (denoland#87)
1 parent 9c4731d commit f58e042

2 files changed

Lines changed: 33 additions & 32 deletions

File tree

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.92.0"
2+
channel = "1.87.0"
33
components = ["rustfmt", "clippy"]

src/lib.rs

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,17 @@ impl UrlPatternInit {
207207
if let Some(pathname) = &self.pathname {
208208
result.pathname = Some(pathname.clone());
209209

210-
if let Some(base_url) = base_url
211-
&& !base_url.cannot_be_a_base()
212-
&& !is_absolute_pathname(pathname, &kind)
213-
{
214-
let baseurl_path = url::quirks::pathname(base_url);
215-
let slash_index = baseurl_path.rfind('/');
216-
if let Some(slash_index) = slash_index {
217-
let new_pathname = baseurl_path[..=slash_index].to_string();
218-
result.pathname =
219-
Some(format!("{}{}", new_pathname, result.pathname.unwrap()));
210+
if let Some(base_url) = base_url {
211+
if !base_url.cannot_be_a_base()
212+
&& !is_absolute_pathname(pathname, &kind)
213+
{
214+
let baseurl_path = url::quirks::pathname(base_url);
215+
let slash_index = baseurl_path.rfind('/');
216+
if let Some(slash_index) = slash_index {
217+
let new_pathname = baseurl_path[..=slash_index].to_string();
218+
result.pathname =
219+
Some(format!("{}{}", new_pathname, result.pathname.unwrap()));
220+
}
220221
}
221222
}
222223

@@ -331,12 +332,12 @@ impl<R: RegExp> UrlPattern<R> {
331332
)?;
332333

333334
// If processedInit["protocol"] is a special scheme and processedInit["port"] is its corresponding default port
334-
if let Some(protocol) = &processed_init.protocol
335-
&& is_special_scheme(protocol)
336-
{
337-
let default_port = special_scheme_default_port(protocol);
338-
if default_port == processed_init.port.as_deref() {
339-
processed_init.port = Some(String::new())
335+
if let Some(protocol) = &processed_init.protocol {
336+
if is_special_scheme(protocol) {
337+
let default_port = special_scheme_default_port(protocol);
338+
if default_port == processed_init.port.as_deref() {
339+
processed_init.port = Some(String::new())
340+
}
340341
}
341342
}
342343

@@ -924,13 +925,13 @@ mod tests {
924925

925926
let match_input = quirks::process_match_input(input, base_url.as_deref());
926927

927-
if let Some(ExpectedMatch::String(s)) = &case.expected_match
928-
&& s == "error"
929-
{
930-
assert!(match_input.is_err());
931-
println!("✅ Passed");
932-
return;
933-
};
928+
if let Some(ExpectedMatch::String(s)) = &case.expected_match {
929+
if s == "error" {
930+
assert!(match_input.is_err());
931+
println!("✅ Passed");
932+
return;
933+
}
934+
}
934935

935936
let input = match_input.expect("failed to parse match input");
936937

@@ -949,14 +950,14 @@ mod tests {
949950
} else {
950951
Ok(None)
951952
};
952-
if let Some(ExpectedMatch::String(s)) = &case.expected_match
953-
&& s == "error"
954-
{
955-
assert!(test_res.is_err());
956-
assert!(exec_res.is_err());
957-
println!("✅ Passed");
958-
return;
959-
};
953+
if let Some(ExpectedMatch::String(s)) = &case.expected_match {
954+
if s == "error" {
955+
assert!(test_res.is_err());
956+
assert!(exec_res.is_err());
957+
println!("✅ Passed");
958+
return;
959+
}
960+
}
960961

961962
let expected_match = case.expected_match.map(|x| match x {
962963
ExpectedMatch::String(_) => unreachable!(),

0 commit comments

Comments
 (0)