Skip to content

Commit

Permalink
Fix Windows drive letter handling in the file slash state
Browse files Browse the repository at this point in the history
Tests: web-platform-tests/wpt#7326.

Fixes #303. Closes #308.
  • Loading branch information
rmisev authored and annevk committed Sep 18, 2017
1 parent 19e0ffa commit 2eef975
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions url.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,34 @@ code point is U+003A (:).
<p class="note">As per the <a href=#url-writing>URL writing</a> section, only a
<a>normalized Windows drive letter</a> is conforming.

<p>A string
<dfn lt="start with a Windows drive letter|starts with a Windows drive letter">starts with a Windows drive letter</dfn>
if all of the following are true:

<ul class=brief>
<li>its <a for=string>length</a> is greater than or equal to 2
<li>its first two code points are a <a>Windows drive letter</a>
<li>its <a for=string>length</a> is 2 or its third code point is U+002F (/), U+005C (\),
U+003F (?), or U+0023 (#).
</ul>

<div class=example id=example-start-with-a-widows-drive-letter>
<table>
<tr>
<th>String
<th>Starts with a Windows drive letter
<tr>
<td>"<code>c:</code>"
<td>
<tr>
<td>"<code>c:/</code>"
<td>
<tr>
<td>"<code>c:a</code>"
<td>
</table>
</div>

<p id=pop-a-urls-path>To <dfn local-lt=shorten>shorten a <var>url</var>'s path</dfn>:

<ol>
Expand Down Expand Up @@ -1834,19 +1862,11 @@ string <var>input</var>, optionally with a <a>base URL</a> <var>base</var>, opti
<dd>
<ol>
<li>
<p>If at least one of the following is true

<ul class=brief>
<li><p><a>remaining</a> consists of zero code points
<li><p><a>c</a> and the first code point of <a>remaining</a> are not a
<a>Windows drive letter</a>
<li><p><a>remaining</a> has at least 2 code points and <a>remaining</a>'s second code
point is <em>not</em> U+002F (/), U+005C (\), U+003F (?), or U+0023 (#)
</ul>

<p>then set <var>url</var>'s <a for=url>host</a> to <var>base</var>'s <a for=url>host</a>,
<var>url</var>'s <a for=url>path</a> to a copy of <var>base</var>'s <a for=url>path</a>,
and then <a>shorten</a> <var>url</var>'s <a for=url>path</a>.
<p>If the substring from <var>pointer</var> in <var>input</var> does not
<a>start with a Windows drive letter</a>, then set <var>url</var>'s <a for=url>host</a> to
<var>base</var>'s <a for=url>host</a>, <var>url</var>'s <a for=url>path</a> to a copy of
<var>base</var>'s <a for=url>path</a>, and then <a>shorten</a> <var>url</var>'s
<a for=url>path</a>.

<p class=note>This is a (platform-independent) Windows drive letter quirk.

Expand Down Expand Up @@ -1877,8 +1897,9 @@ string <var>input</var>, optionally with a <a>base URL</a> <var>base</var>, opti

<ol>
<li>
<p>If <var>base</var> is non-null and <var>base</var>'s <a for=url>scheme</a> is
"<code>file</code>", then:
<p>If <var>base</var> is non-null, <var>base</var>'s <a for=url>scheme</a> is
"<code>file</code>", and the substring from <var>pointer</var> in <var>input</var> does not
<a>start with a Windows drive letter</a>, then:

<ol>
<li>
Expand Down

0 comments on commit 2eef975

Please sign in to comment.