diff --git a/url/src/lib.rs b/url/src/lib.rs index 5e2e50728..e59c570da 100644 --- a/url/src/lib.rs +++ b/url/src/lib.rs @@ -1723,6 +1723,32 @@ impl Url { ); } }); + + // To handle cases like set pathname to + // For instance, //p should be converted to /..//p here + // At this point, we would get "non-spec://p" for serialization + // and "/..//p" for path + if let Some(path_pos) = path.rfind("//") { + if let Some(serialization_pos) = self.serialization.rfind("//") { + const PATH_INCREMENT: usize = 2; // length of "/." + + if path_pos + PATH_INCREMENT <= path.len() + && serialization_pos + PATH_INCREMENT <= self.serialization.len() + { + let rest_path = &path[(path_pos + PATH_INCREMENT)..]; + let rest_serialization = + &self.serialization[(serialization_pos + PATH_INCREMENT)..]; + + // rest should be the same + if rest_path == rest_serialization { + self.serialization + .replace_range(serialization_pos.., &format!("/.//{}", rest_path)); + self.path_start += PATH_INCREMENT as u32; + } + } + } + } + self.restore_after_path(old_after_path_pos, &after_path); } diff --git a/url/tests/expected_failures.txt b/url/tests/expected_failures.txt index 91145db79..2f83201c5 100644 --- a/url/tests/expected_failures.txt +++ b/url/tests/expected_failures.txt @@ -44,7 +44,4 @@ set pathname to <\\\\> set pathname to set pathname to - set pathname to - set pathname to - set pathname to set pathname to