Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup API for file and non-special URLs #224

Merged
merged 4 commits into from
Feb 8, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 69 additions & 21 deletions url.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,10 @@ string <var>input</var>, optionally with a <a>base URL</a> <var>base</var>, opti
<!-- http://? -> failure
test://? -> test://? -->

<li><p>Otherwise, if <var>state override</var> is given, <var>buffer</var> is the empty
string, and either <var>url</var> <a>includes credentials</a> or <var>url</var>'s
<a for=url>port</a> is non-null, <a>syntax violation</a>, return.

<li><p>Let <var>host</var> be the result of <a lt="URL-host parser">URL-host parsing</a>
<var>buffer</var> with <var>url</var> <a>is special</a>.

Expand Down Expand Up @@ -1859,28 +1863,42 @@ string <var>input</var>, optionally with a <a>base URL</a> <var>base</var>, opti

<ol>
<li>
<p>If <var>buffer</var> is a <a>Windows drive letter</a>, <a>syntax violation</a>,
set <var>state</var> to <a>path state</a>.

<p class=note>This is a (platform-independent) Windows drive letter quirk.
<var>buffer</var> is not reset here and instead used in the
<p>If <var>state override</var> is not given and <var>buffer</var> is a
<a>Windows drive letter</a>, <a>syntax violation</a>, set <var>state</var> to
<a>path state</a>.

<li><p>Otherwise, if <var>buffer</var> is the empty string, set
<var>state</var> to <a>path start state</a>.
<p class=note>This is a (platform-independent) Windows drive letter quirk. <var>buffer</var>
is not reset here and instead used in the <a>path state</a>.

<li>
<p>Otherwise, if <var>buffer</var> is the empty string, then:

<ol>
<li><p>If <var>state override</var> is given and <var>url</var>
<a>includes credentials</a>, <a>syntax violation</a>, return.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "return" the same as "terminate this algorithm" elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I'm slowly switching to Infra terminology.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the inconsistency is pretty confusing; when I implemented in whatwg-url I accidentally translated "return" as "bail out of the entire URL parsing algorithm".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that what's happening?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No; it's bailing out of this particular state and back into the main parser loop. I.e. it goes back to step 11 ("Keep running the following state machine by switching on state. If after a run pointer points to EOF code point, go to the next step. Otherwise, increase pointer by one and continue with the state machine.")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err, nevermind, that is what's happening. I guess what I meant is that I translated this as "bail out of this step and go back to step 11". Basically I saw two different types of bail-outs, and since I knew that "abort these steps" meant the one, I assumed that "return" meant the other one. I think it's best to change them all at once or not at all.


<li><p>Set <var>url</var>'s <a for=url>host</a> to the empty string.

<li><p>If <var>state override</var> is given, then return.

<li><p>Set <var>state</var> to <a>path start state</a>.
</ol>

<li>
<p>Otherwise, run these steps:

<ol>
<li><p>Let <var>host</var> be the result of
<a lt='host parser'>host parsing</a>
<li><p>Let <var>host</var> be the result of <a lt="host parser">host parsing</a>
<var>buffer</var>.

<li><p>If <var>host</var> is failure, return failure.
<li><p>If <var>host</var> is failure, then return failure.

<li><p>If <var>host</var> is "<code title>localhost</code>", then set <var>host</var> to
the empty string.

<li><p>Set <var>url</var>'s <a for=url>host</a> to <var>host</var>.

<li><p>If <var>host</var> is not "<code title>localhost</code>", set
<var>url</var>'s <a for=url>host</a> to <var>host</var>.
<li><p>If <var>state override</var> is given, then return.

<li><p>Set <var>buffer</var> to the empty string and <var>state</var> to
<a>path start state</a>.
Expand Down Expand Up @@ -2622,8 +2640,16 @@ compatibility with HTML's <code>MessageEvent</code> feature. [[!HTML]]
<p>The <code><a attribute for=URL>username</a></code> attribute's setter must run these steps:

<ol>
<li><p>If <a>context object</a>'s <a for=URL>url</a>'s <a for=url>host</a> is null, or its
<a for=url>cannot-be-a-base-URL flag</a> is set, terminate these steps.
<li>
<p>If one of the following regarding <a>context object</a>'s <a for=URL>url</a> is true

<ul class=brief>
<li><p>its <a for=url>host</a> is null or the empty string
<li><p>its <a for=url>cannot-be-a-base-URL flag</a> is set
<li><p>its <a for=url>scheme</a> is "<code>file</code>"
</ul>

<p>then return.

<li><p><a for=url>Set the username</a> given <a>context object</a>'s <a for=URL>url</a> and the
given value.
Expand All @@ -2635,8 +2661,16 @@ compatibility with HTML's <code>MessageEvent</code> feature. [[!HTML]]
<p>The <code><a attribute for=URL>password</a></code> attribute's setter must run these steps:

<ol>
<li><p>If <a>context object</a>'s <a for=URL>url</a>'s <a for=url>host</a> is null, or its
<a for=url>cannot-be-a-base-URL flag</a> is set, terminate these steps.
<li>
<p>If one of the following regarding <a>context object</a>'s <a for=URL>url</a> is true

<ul class=brief>
<li><p>its <a for=url>host</a> is null or the empty string
<li><p>its <a for=url>cannot-be-a-base-URL flag</a> is set
<li><p>its <a for=url>scheme</a> is "<code>file</code>"
</ul>

<p>then return.

<li><p><a for=url>Set the password</a> given <a>context object</a>'s <a for=URL>url</a> and the
given value.
Expand All @@ -2663,8 +2697,11 @@ compatibility with HTML's <code>MessageEvent</code> feature. [[!HTML]]
<li><p>If <a>context object</a>'s <a for=URL>url</a>'s <a for=url>cannot-be-a-base-URL flag</a> is
set, terminate these steps.

<li><p>Let <var>hostState</var> be <a>file host state</a> if <a>context object</a>'s
<a for=URL>url</a>'s <a for=url>scheme</a> is "<code>file</code>", and <a>host state</a> otherwise.

<li><p><a lt="basic URL parser">Basic URL parse</a> the given value with <a>context object</a>'s
<a for=URL>url</a> as <var>url</var> and <a>host state</a> as <var>state override</var>.
<a for=URL>url</a> as <var>url</var> and <var>hostState</var> as <var>state override</var>.
</ol>

<p class="note no-backref">If the given value for the <code><a attribute for=URL>host</a></code>
Expand All @@ -2689,8 +2726,12 @@ the setter to always "reset" both.
<li><p>If <a>context object</a>'s <a for=URL>url</a>'s <a for=url>cannot-be-a-base-URL flag</a> is
set, terminate these steps.

<li><p>Let <var>hostState</var> be <a>file host state</a> if <a>context object</a>'s
<a for=URL>url</a>'s <a for=url>scheme</a> is "<code>file</code>", and <a>hostname state</a>
otherwise.

<li><p><a lt="basic URL parser">Basic URL parse</a> the given value with <a>context object</a>'s
<a for=URL>url</a> as <var>url</var> and <a>hostname state</a> as <var>state override</var>.
<a for=URL>url</a> as <var>url</var> and <var>hostState</var> as <var>state override</var>.
</ol>

<p>The <dfn attribute for=URL><code>port</code></dfn> attribute's getter must run these steps:
Expand All @@ -2706,9 +2747,16 @@ the setter to always "reset" both.
<p>The <code><a attribute for=URL>port</a></code> attribute's setter must run these steps:

<ol>
<li><p>If <a>context object</a>'s <a for=URL>url</a>'s <a for=url>host</a> is null, its
<a for=url>cannot-be-a-base-URL flag</a> is set, or its <a for=url>scheme</a> is
"<code>file</code>", terminate these steps.
<li>
<p>If one of the following regarding <a>context object</a>'s <a for=URL>url</a> is true

<ul class=brief>
<li><p>its <a for=url>host</a> is null or the empty string
<li><p>its <a for=url>cannot-be-a-base-URL flag</a> is set
<li><p>its <a for=url>scheme</a> is "<code>file</code>"
</ul>

<p>then return.

<li><p>If the given value is the empty string, then set <a for=URL>url</a>'s <a for=url>port</a> to
null.</p></li>
Expand Down