Re: [whatwg/url] Non-special URLs were not idempotent (#505)

@rmisev requested changes on this pull request.



> + <li>
+  <p>Otherwise:
+
+  <ol>
+   <li><p>Let <var>path</var> be a <a for=list>clone</a> of <var>url</var>'s <a for=url>path</a>.
+
+   <li><p>If <var>url</var>'s <a for=url>host</a> is null, <var>path</var>'s <a for=list>size</a> is
+   greater than 1, and <var>path</var>[0] is the empty string, then append U+002F (/) followed by
+   U+002E (.) to <var>output</var> and <a for=list>remove</a> <var>path</var>[0] from
+   <var>path</var>.
+
+   <li><p><a for=list>For each</a> <var>segment</var> of <var>path</var>: append U+002F (/) followed
+   by <var>segment</var> to <var>output</var>.
+  </ol>
+
+  <p class=note>This prevents <code>web+demo:/./not-a-host/</code> or

`web+demo:/./not-a-host/` currently is parsed to `web+demo:/not-a-host/` - so it hasn't reparsing problem. I think there must be `web+demo:/.//not-a-host/`

> +  <ol>
+   <li><p>Let <var>path</var> be a <a for=list>clone</a> of <var>url</var>'s <a for=url>path</a>.
+
+   <li><p>If <var>url</var>'s <a for=url>host</a> is null, <var>path</var>'s <a for=list>size</a> is
+   greater than 1, and <var>path</var>[0] is the empty string, then append U+002F (/) followed by
+   U+002E (.) to <var>output</var> and <a for=list>remove</a> <var>path</var>[0] from
+   <var>path</var>.
+
+   <li><p><a for=list>For each</a> <var>segment</var> of <var>path</var>: append U+002F (/) followed
+   by <var>segment</var> to <var>output</var>.
+  </ol>
+
+  <p class=note>This prevents <code>web+demo:/./not-a-host/</code> or
+  <code>web+demo:/path/..//not-a-host/</code>, when <a lt="URL parser">parsed</a> and then
+  <a lt="URL serializer">serialized</a>, from ending up as <code>web+demo://not-a-host/</code> (they
+  end up as <code>web+demo:/./not-a-host/</code>).

The same: `web+demo:/.//not-a-host/`

> +   <li><p>Let <var>path</var> be a <a for=list>clone</a> of <var>url</var>'s <a for=url>path</a>.
+
+   <li><p>If <var>url</var>'s <a for=url>host</a> is null, <var>path</var>'s <a for=list>size</a> is
+   greater than 1, and <var>path</var>[0] is the empty string, then append U+002F (/) followed by
+   U+002E (.) to <var>output</var> and <a for=list>remove</a> <var>path</var>[0] from
+   <var>path</var>.

There's no need to remove path[0] from path, consequently no need to create clone of path (see my comment below).

-- 
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/pull/505#pullrequestreview-408682790

Received on Sunday, 10 May 2020 18:57:57 UTC