From 3ded72a19e9df1d08ebdc37e8f673908985dd035 Mon Sep 17 00:00:00 2001 From: Dylan O'Toole Date: Mon, 1 Apr 2024 17:01:39 -0400 Subject: [PATCH] Non-special URLs can have their paths erased --- url/src/quirks.rs | 5 ++++- url/tests/expected_failures.txt | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/url/src/quirks.rs b/url/src/quirks.rs index 3a99e22cf..61baa7e2b 100644 --- a/url/src/quirks.rs +++ b/url/src/quirks.rs @@ -279,11 +279,14 @@ pub fn set_pathname(url: &mut Url, new_pathname: &str) { && new_pathname.starts_with('\\')) { url.set_path(new_pathname) - } else { + } else if SchemeType::from(url.scheme()).is_special() || !new_pathname.is_empty() || !url.has_host() { let mut path_to_set = String::from("/"); path_to_set.push_str(new_pathname); url.set_path(&path_to_set) } + else { + url.set_path(new_pathname) + } } /// Getter for https://url.spec.whatwg.org/#dom-url-search diff --git a/url/tests/expected_failures.txt b/url/tests/expected_failures.txt index 168a8327f..91145db79 100644 --- a/url/tests/expected_failures.txt +++ b/url/tests/expected_failures.txt @@ -38,7 +38,6 @@ set hostname to set hostname to set hostname to <> - set pathname to <> set pathname to <> set port to set href to