Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions url/resources/setters_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,51 @@
"pathname": "me@example.net"
}
},
{
"comment": "Special URLs cannot have their paths erased",
"href": "file:///some/path",
"new_value": "",
"expected": {
"href": "file:///",
"pathname": "/"
}
},
{
"comment": "Non-special URLs can have their paths erased",
"href": "foo://somehost/some/path",
"new_value": "",
"expected": {
"href": "foo://somehost",
"pathname": ""
}
},
{
"comment": "Non-special URLs with an empty host can have their paths erased",
"href": "foo:///some/path",
"new_value": "",
"expected": {
"href": "foo://",
"pathname": ""
}
},
{
"comment": "Path-only URLs cannot have their paths erased",
"href": "foo:/some/path",
"new_value": "",
"expected": {
"href": "foo:/",
"pathname": "/"
}
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add a test where the new pathname value is non-empty but rootless, like "test"? A root should be automatically created in that case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also add a test setting a path on a URL without a host? My initial late-night implementation of this change would've failed that test. Like this:

  •    {
    
  •        "comment": "Non-special URLs can have their paths erased",
    
  •        "href": "foo:///some/path",
    
  •        "new_value": "",
    
  •        "expected": {
    
  •            "href": "foo://",
    
  •            "pathname": ""
    
  •        }
    
  •    },
    

{
"comment": "Path-only URLs always have an initial slash",
"href": "foo:/some/path",
"new_value": "test",
"expected": {
"href": "foo:/test",
"pathname": "/test"
}
},
{
"href": "unix:/run/foo.socket?timeout=10",
"new_value": "/var/log/../run/bar.socket",
Expand Down