Skip to content

Commit

Permalink
Non-special URLs were not idempotent
Browse files Browse the repository at this point in the history
Adjust the URL serializer so it does not output something which during the next parse operation would yield a host.

whatwg-url: jsdom/whatwg-url#148.

Tests: web-platform-tests/wpt#25113.

Fixes #415.
  • Loading branch information
annevk authored Aug 24, 2020
1 parent cf05fda commit 83adf0c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions url.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2542,8 +2542,22 @@ then runs these steps, returning an <a>ASCII string</a>:
<li><p>If <var>url</var>'s <a for=url>cannot-be-a-base-URL flag</a> is set, append <var>url</var>'s
<a for=url>path</a>[0] to <var>output</var>.

<li><p>Otherwise, then <a for=list>for each</a> string in <var>url</var>'s <a for=url>path</a>,
append U+002F (/) followed by the string to <var>output</var>.
<li>
<p>Otherwise:

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

<li><p><a for=list>For each</a> <var>segment</var> of <var>url</var>'s <a for=url>path</a>:
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>).

<li><p>If <var>url</var>'s <a for=url>query</a> is non-null, append
U+003F (?), followed by <var>url</var>'s <a for=url>query</a>, to
Expand Down Expand Up @@ -3480,8 +3494,9 @@ Valentin Gosu,
Vyacheslav Matva,
Wei Wang,
山岸和利 (Yamagishi Kazutoshi),
Yongsheng Zhang, and
成瀬ゆい (Yui Naruse)
Yongsheng Zhang,
成瀬ゆい (Yui Naruse), and
zealousidealroll
for being awesome!

<p>This standard is written by
Expand Down

0 comments on commit 83adf0c

Please sign in to comment.