Skip to content

Commit

Permalink
Editorial: deduplicate the relative state
Browse files Browse the repository at this point in the history
Helps with #504.
  • Loading branch information
annevk authored May 11, 2020
1 parent 68aad5d commit e5b1dd7
Showing 1 changed file with 18 additions and 53 deletions.
71 changes: 18 additions & 53 deletions url.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1716,12 +1716,16 @@ string <var>input</var>, optionally with a <a>base URL</a> <var>base</var>, opti
<ol>
<li><p>Set <var>url</var>'s <a for=url>scheme</a> to <var>base</var>'s <a for=url>scheme</a>.

<li><p>If <a>c</a> is U+002F (/), then set <var>state</var> to <a>relative slash state</a>.

<li><p>Otherwise, if <var>url</var> <a>is special</a> and <a>c</a> is U+005C (\),
<a>validation error</a>, set <var>state</var> to <a>relative slash state</a>.

<li>
<p>Switch on <a>c</a>:
<p>Otherwise:

<dl class=switch>
<dt>The <a>EOF code point</a>
<dd><p>Set <var>url</var>'s <a for=url>username</a> to
<ol>
<li><p>Set <var>url</var>'s <a for=url>username</a> to
<var>base</var>'s <a for=url>username</a>,
<var>url</var>'s <a for=url>password</a> to
<var>base</var>'s <a for=url>password</a>,
Expand All @@ -1734,62 +1738,23 @@ string <var>input</var>, optionally with a <a>base URL</a> <var>base</var>, opti
<var>url</var>'s <a for=url>query</a> to
<var>base</var>'s <a for=url>query</a>.

<dt>U+002F (/)
<dd><p>Set <var>state</var> to <a>relative slash state</a>.

<dt>U+003F (?)
<dd><p>Set <var>url</var>'s <a for=url>username</a> to
<var>base</var>'s <a for=url>username</a>,
<var>url</var>'s <a for=url>password</a> to
<var>base</var>'s <a for=url>password</a>,
<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>port</a> to
<var>base</var>'s <a for=url>port</a>,
<var>url</var>'s <a for=url>path</a> to a <a for=list>clone</a> of
<var>base</var>'s <a for=url>path</a>,
<var>url</var>'s <a for=url>query</a> to the empty string, and
<var>state</var> to <a>query state</a>.

<dt>U+0023 (#)
<dd><p>Set <var>url</var>'s <a for=url>username</a> to
<var>base</var>'s <a for=url>username</a>,
<var>url</var>'s <a for=url>password</a> to
<var>base</var>'s <a for=url>password</a>,
<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>port</a> to
<var>base</var>'s <a for=url>port</a>,
<var>url</var>'s <a for=url>path</a> to a <a for=list>clone</a> of
<var>base</var>'s <a for=url>path</a>,
<var>url</var>'s <a for=url>query</a> to
<var>base</var>'s <a for=url>query</a>,
<var>url</var>'s <a for=url>fragment</a> to the empty string, and
<var>state</var> to <a>fragment state</a>.
<li><p>If <a>c</a> is U+003F (?), then set <var>url</var>'s <a for=url>query</a> to the empty
string, and <var>state</var> to <a>query state</a>.

<dt>Otherwise
<dd>
<p>If <var>url</var> <a>is special</a> and <a>c</a> is U+005C (\), <a>validation error</a>,
set <var>state</var> to <a>relative slash state</a>.
<li><p>Otherwise, if <a>c</a> is U+0023 (#), set <var>url</var>'s <a for=url>fragment</a> to
the empty string and <var>state</var> to <a>fragment state</a>.

<p>Otherwise, run these steps:
<li>
<p>Otherwise, if <a>c</a> is not the <a>EOF code point</a>:

<ol>
<li><p>Set <var>url</var>'s <a for=url>username</a> to
<var>base</var>'s <a for=url>username</a>,
<var>url</var>'s <a for=url>password</a> to
<var>base</var>'s <a for=url>password</a>,
<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>port</a> to
<var>base</var>'s <a for=url>port</a>,
<var>url</var>'s <a for=url>path</a> to a <a for=list>clone</a> of
<var>base</var>'s <a for=url>path</a>, and then <a for=list>remove</a>
<var>url</var>'s <a for=url>path</a>'s last item, if any.
<li><p>Set <var>url</var>'s <a for=url>query</a> to null.

<li><p><a for=list>Remove</a> <var>url</var>'s <a for=url>path</a>'s last item, if any.

<li><p>Set <var>state</var> to <a>path state</a> and decrease <var>pointer</var> by 1.
</ol>
</dl>
</ol>
</ol>

<dt><dfn>relative slash state</dfn>
Expand Down

0 comments on commit e5b1dd7

Please sign in to comment.