Skip to content

Leading slashes are dropped while setting pathname for file urls #1118

@kt3k

Description

@kt3k
use url::Url;

fn main() {
    let mut u = Url::parse("file:///").unwrap();
    u.set_path("//foo");
    println!("{}", u);
}

This should prints file:////foo instead of file:///foo.

Note: The below prints file:////foo in all major browsers

const a = new URL("file:///");
a.pathname = "//foo";
console.log(a.href);

This behavior affects the WPT cases below:

<file://monkey/> set pathname to <\\\\>
<file:///unicorn> set pathname to <//\\/>
<file:///unicorn> set pathname to <//monkey/..//>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions