- From: Yutaka Hirano <notifications@github.com>
- Date: Tue, 14 Feb 2017 23:58:17 -0800
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/url/issues/232/279941700@github.com>
Let me check my understanding.
According to [RFC3986](https://www.ietf.org/rfc/rfc3986.txt), `path` can start with multiple slashes only when `authority` is present. Note that `authority` can be empty as `reg-name` can be empty.
```
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
hier-part = "//" authority path-abempty
/ path-absolute
/ path-rootless
/ path-empty
...
authority = [ userinfo "@" ] host [ ":" port ]
host = IP-literal / IPv4address / reg-name
reg-name = *( unreserved / pct-encoded / sub-delims )
...
path-abempty = *( "/" segment )
path-absolute = "/" [ segment-nz *( "/" segment ) ]
path-noscheme = segment-nz-nc *( "/" segment )
path-rootless = segment-nz *( "/" segment )
path-empty = 0<pchar>
segment = *pchar
segment-nz = 1*pchar
segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
; non-zero-length segment without any colon ":"
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
```
So, after seeing "file:",
- If the parser sees "//":
`authority` follows (note that it can be empty), followed by `path-abempty` which is either empty or starting with (possible multiple) slashes.
- Otherwise, if the parser sees "/":
`path-absolute` follows (including the "/"). Note that `path-absolute` cannot start with "//".
- Otherwise:
...
Here are some examples:
| input | host | path | comment |
|---|--|--|--|
| file:/x/y/z | n/a | /x/y/z | `authority` is not present |
| file://x/y/z | x | /y/z | |
| file://x//y/z | x | //y/z | |
| file:///x/y/z | | /x/y/z | `authority` is empty |
| file:////x/y/z | | //x/y/z | `authority` is empty |
| file:/localhost/y/z | n/a | /localhost/y/z | `authority` is not present |
| file://localhost/y/z | localhost | /y/z | |
| file:///localhost/y/z | | /localhost/y/z | `authority` is empty |
Please correct me if I'm wrong.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/232#issuecomment-279941700
Received on Wednesday, 15 February 2017 07:58:51 UTC