Re: [whatwg/url] "append the empty string to url’s path." is confusing (#295)

That has the same result as just a `/`, as they will chiefly go through step 2:

> 2. If _buffer_ is a double-dot path segment, shorten _url_’s path, and then if neither _c_ is U+002F (/), nor _url_ is special and _c_ is U+005C (\), append the empty string to _url_’s path.

where [shorten a URL's path](https://url.spec.whatwg.org/#shorten-a-urls-path) is specified to only remove the last item from the path if the path is not empty.

After the first `/`, path is still empty.

After the first set of `../`, path is shortened, but since it was empty before there is no change to path at all.

Repeat the this process, and when _c_ is the EOF code point, _buffer_ is `..`, _url_'s path is still empty. Step 2 first shortens the path (again, it remains empty), but since _c_ is not `/` or `\` an empty string is added to the path after shortening.

So in the end we get a path with one element, the empty string.

Which part is confusing? The name to "shorten a _url_’s path" when it is really "shorten path if possible"?

-- 
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/295#issuecomment-296338374

Received on Saturday, 22 April 2017 01:37:51 UTC