Skip to content

Commit

Permalink
Define a set the input algorithm and define other algorithms in terms…
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Feb 14, 2013
1 parent 5af7710 commit 4253baf
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 118 deletions.
133 changes: 73 additions & 60 deletions url.html
Expand Up @@ -7,7 +7,7 @@

<p><a class="logo" href="//www.whatwg.org/"><img alt="WHATWG" height="100" src="//resources.whatwg.org/logo-url.svg" width="100"></a></p>
<h1>URL</h1>
<h2 class="no-num no-toc" id="living-standard-—-last-updated-13-february-2013">Living Standard — Last Updated 13 February 2013</h2>
<h2 class="no-num no-toc" id="living-standard-—-last-updated-14-february-2013">Living Standard — Last Updated 14 February 2013</h2>

<dl>
<dt>This Version:
Expand Down Expand Up @@ -35,7 +35,7 @@ <h2 class="no-num no-toc" id="living-standard-—-last-updated-13-february-2013"
<p class="copyright"><a href="http://creativecommons.org/publicdomain/zero/1.0/" rel="license"><img alt="CC0" src="http://i.creativecommons.org/p/zero/1.0/80x15.png"></a>
To the extent possible under law, the editors have waived all copyright and
related or neighboring rights to this work. In addition, as of
13 February 2013, the editors have made this specification available
14 February 2013, the editors have made this specification available
under the
<a href="http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0" rel="license">Open Web Foundation Agreement Version 1.0</a>,
which is available at
Expand Down Expand Up @@ -1779,6 +1779,21 @@ <h2 id="api"><span class="secno">7 </span>API</h2>
URLPath would be a subclassed Array similarly to how URLQuery will be a
subclassed MultiMap. -->

<p>Specifications defining objects implementing <a href="#urlutils"><code>URLUtils</code></a> must define a
<dfn id="concept-uu-get-the-base" title="concept-UU-get-the-base">get the base</dfn> algorithm, which must return the
appropriate <a href="#concept-base-url" title="concept-base-URL">base URL</a> for the object.

<p>Specifications defining objects implementing <a href="#urlutils"><code>URLUtils</code></a> may
define <dfn id="concept-uu-update" title="concept-UU-update">update steps</dfn> to make it possible
for an underlying object (such as an
<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-attribute-value" title="concept-attribute-value">attribute value</a>)
to be updated.

<p class="note">The <a href="#concept-uu-update" title="concept-UU-update">update steps</a> are
always invoked after each potential modification. Specifications need to
keep track themselves if an actual modification is made, if they wish to
make that distinction.

<p>An object implementing <a href="#urlutils"><code>URLUtils</code></a> has an associated
<dfn id="concept-uu-input" title="concept-UU-input">input</dfn> (a string),
<dfn id="concept-uu-query-encoding" title="concept-UU-query-encoding">query encoding</dfn>
Expand All @@ -1788,40 +1803,58 @@ <h2 id="api"><span class="secno">7 </span>API</h2>
<dfn id="concept-uu-url" title="concept-UU-url">url</dfn> (a
<a href="#concept-parsed-url" title="concept-parsed-url">parsed URL</a> or null).

Unless stated otherwise,
<a href="#concept-uu-query-encoding" title="concept-UU-query-encoding">query encoding</a> is
<a class="external" data-anolis-spec="encoding" href="http://encoding.spec.whatwg.org/#utf-8">utf-8</a>, and
<a href="#concept-uu-query-object" title="concept-UU-query-object">query object</a> and
<a href="#concept-uu-url" title="concept-UU-url">url</a> are null. The others must be set on
creation by the specification using <a href="#urlutils"><code>URLUtils</code></a>.
Unless stated otherwise, <a href="#concept-uu-query-encoding" title="concept-UU-query-encoding">query encoding</a> is
<a class="external" data-anolis-spec="encoding" href="http://encoding.spec.whatwg.org/#utf-8">utf-8</a>. The others follow from the
<a href="#concept-uu-set-the-input" title="concept-UU-set-the-input">set the input</a> algorithm.

<p class="note">The associated
<a href="#concept-uu-query-encoding" title="concept-UU-query-encoding">query encoding</a> is a legacy
concept only relevant for HTML.
<a class="informative" href="#refsHTML">[HTML]</a>

<p>When an object implementing <a href="#urlutils"><code>URLUtils</code></a> is created with a
non-null <a href="#concept-uu-url" title="concept-UU-url">url</a> whose
<a href="#relative-flag">relative flag</a> is set,
<a href="#concept-uu-query-object" title="concept-UU-query-object">query object</a> must be set to a
<a href="#concept-uq-new" title="concept-UQ-new">new <code>URLQuery</code> object</a> using
<a href="#concept-uu-url" title="concept-UU-url">url</a>'s
<a href="#concept-url-query" title="concept-URL-query">query</a>.
<p>Specifications defining objects implementing <a href="#urlutils"><code>URLUtils</code></a> must use the
<a href="#concept-uu-set-the-input" title="concept-UU-set-the-input">set the input</a> algorithms to set
<a href="#concept-uu-input" title="concept-UU-input">input</a>, <a href="#concept-uu-url" title="concept-UU-url">url</a>, and
<a href="#concept-uu-query-object" title="concept-UU-query-object">query object</a>. To
<dfn id="concept-uu-set-the-input" title="concept-UU-set-the-input">set the input</dfn> run these steps:

<p>An object implementing <a href="#urlutils"><code>URLUtils</code></a> also has an associated
<dfn id="concept-uu-get-the-base" title="concept-UU-get-the-base">get the base</dfn> algorithm, which has to return the
appropriate <a href="#concept-base-url" title="concept-base-URL">base URL</a> for the object.
<ol>
<li><p>Set <a href="#concept-uu-url" title="concept-UU-url">url</a> null.

<p>Specifications defining objects implementing <a href="#urlutils"><code>URLUtils</code></a> may
define <dfn id="concept-uu-update" title="concept-UU-update">update steps</dfn> to make it possible
for an underlying object (such as an
<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-attribute-value" title="concept-attribute-value">attribute value</a>)
to be updated.
<li><p>Set <a href="#concept-uu-input" title="concept-UU-input">input</a> to the given value.

<p class="note">The <a href="#concept-uu-update" title="concept-UU-update">update steps</a> are
always invoked after each potential modification. Specifications need to
keep track themselves if an actual modification is made, if they wish to
make that distinction.
<li><p>Let <var title="">parsed URL</var> be the result of
<a href="#concept-url-parser" title="concept-url-parser">parsing</a>
<a href="#concept-uu-input" title="concept-UU-input">input</a> with
<a href="#concept-base-url" title="concept-base-url">base URL</a> being the result of running
<a href="#concept-uu-get-the-base" title="concept-UU-get-the-base">get the base</a> and
<a href="#concept-uu-query-encoding" title="concept-UU-query-encoding">query encoding</a> as
<var title="">encoding override</var>.

<li><p>If <var title="">parsed URL</var> is not failure, set
<a href="#concept-uu-url" title="concept-UU-url">url</a> to <var title="">parsed URL</var>.

<li>
<p>If <a href="#concept-uu-url" title="concept-UU-url">url</a> is non-null and its
<a href="#relative-flag">relative flag</a> is set, run these substeps:

<ol>
<li><p>If <a href="#concept-uu-query-object" title="concept-UU-query-object">query object</a> is null, set
<a href="#concept-uu-query-object" title="concept-UU-query-object">query object</a> to a
<a href="#concept-uq-new" title="concept-UQ-new">new <code>URLQuery</code> object</a> using
<a href="#concept-uu-url" title="concept-UU-url">url</a>'s <a href="#concept-url-query" title="concept-URL-query">query</a>.

<li><p>Otherwise, set <a href="#concept-uu-query-object" title="concept-UU-query-object">query object</a>'s
associated list of name-value pairs to the result of
<a href="#concept-urlencoded-parser" title="concept-urlencoded-parser">parsing</a>
<a href="#concept-uu-url" title="concept-UU-url">url</a>'s <a href="#concept-url-query" title="concept-URL-query">query</a>.
</ol>

<li><p>If <a href="#concept-uu-url" title="concept-UU-url">url</a> is null and
<a href="#concept-uu-query-object" title="concept-UU-query-object">query object</a> is non-null, empty
<a href="#concept-uu-query-object" title="concept-UU-query-object">query object</a>'s associated list of name-value
pairs.
</ol>


<h3 id="constructors"><span class="secno">7.1 </span>Constructors</h3> <!-- "constructor" causes dfn.js to fail -->
Expand All @@ -1838,20 +1871,20 @@ <h3 id="constructors"><span class="secno">7.1 </span>Constructors</h3> <!-- "con
<li><p>If <var title="">base</var> is failure,
<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> an
"<a href="http://dom.spec.whatwg.org/#syntaxerror"><code class="external" data-anolis-spec="dom">SyntaxError</code></a>" exception.

<li><p>Let <var title="">parsed URL</var> be the result of
<a href="#concept-url-parser" title="concept-url-parser">parsing</a> <var title="">url</var>
with <a href="#concept-base-url" title="concept-base-url">base URL</a> <var title="">base</var>.

<li><p>If <var title="">parsed URL</var> is failure,

<li><p>Let <var title="">result</var> be a new <code>URL object</code>.

<li><p>Let <var title="">result</var>'s
<a href="#concept-uu-get-the-base" title="concept-UU-get-the-base">get the base</a> return <var title="">base</var>.

<li><p>Run <var title="">result</var>'s
<a href="#concept-uu-set-the-input" title="concept-UU-set-the-input">set the input</a> for <var title="">url</var>.

<li><p>If <var title="">result</var>'s <a href="#concept-uu-url" title="concept-UU-url">url</a> is null,
<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> an
"<a href="http://dom.spec.whatwg.org/#syntaxerror"><code class="external" data-anolis-spec="dom">SyntaxError</code></a>" exception.

<li><p>Create a new <a href="#url"><code>URL</code></a> object, set its
<a href="#concept-uu-url" title="concept-UU-url">url</a> to <var title="">parsed URL</var>,
<a href="#concept-uu-input" title="concept-UU-input">input</a> to <var title="">url</var>, and make its
<a href="#concept-uu-get-the-base" title="concept-UU-get-the-base">get the base</a> algorithm return
<var title="">base</var>, and then return the new object.
<li><p>Return <var title="">result</var>.
</ol>


Expand All @@ -1875,28 +1908,8 @@ <h3 id="interface-urlutils"><span class="secno">7.2 </span>Interface <a href="#u
run these steps:

<ol>
<li><p>Set <a href="#concept-uu-url" title="concept-UU-url">url</a> and
<a href="#concept-uu-query-object" title="concept-UU-query-object">query object</a> to null.

<li><p>Set <a href="#concept-uu-input" title="concept-UU-input">input</a> to the given value.

<li><p>Let <var title="">parsed URL</var> be the result of
<a href="#concept-url-parser" title="concept-url-parser">parsing</a>
<a href="#concept-uu-input" title="concept-UU-input">input</a> with
<a href="#concept-base-url" title="concept-base-url">base URL</a> being the result of running
<a href="#concept-uu-get-the-base" title="concept-UU-get-the-base">get the base</a> and
<a href="#concept-uu-query-encoding" title="concept-UU-query-encoding">query encoding</a> as
<var title="">encoding override</var>.

<li><p>If <var title="">parsed URL</var> is not failure, set
<a href="#concept-uu-url" title="concept-UU-url">url</a> to <var title="">parsed URL</var>.

<li><p>If <a href="#concept-uu-url" title="concept-UU-url">url</a> is non-null and its
<a href="#relative-flag">relative flag</a> is set, set
<a href="#concept-uu-query-object" title="concept-UU-query-object">query object</a> to a
<a href="#concept-uq-new" title="concept-UQ-new">new <code>URLQuery</code> object</a> using
<a href="#concept-uu-url" title="concept-UU-url">url</a>'s
<a href="#concept-url-query" title="concept-URL-query">query</a>.
<li><p>Run the <a href="#concept-uu-set-the-input" title="concept-UU-set-the-input">set the input</a> algorithm for
the given value.

<li><p>Run the <a href="#concept-uu-update" title="concept-UU-update">update steps</a>.
</ol>
Expand Down
129 changes: 71 additions & 58 deletions url.src.html
Expand Up @@ -1756,6 +1756,21 @@ <h2>API</h2>
URLPath would be a subclassed Array similarly to how URLQuery will be a
subclassed MultiMap. -->

<p>Specifications defining objects implementing <code>URLUtils</code> must define a
<dfn title=concept-UU-get-the-base>get the base</dfn> algorithm, which must return the
appropriate <span title=concept-base-URL>base URL</span> for the object.

<p>Specifications defining objects implementing <code>URLUtils</code> may
define <dfn title=concept-UU-update>update steps</dfn> to make it possible
for an underlying object (such as an
<span data-anolis-spec=dom title=concept-attribute-value>attribute value</span>)
to be updated.

<p class=note>The <span title=concept-UU-update>update steps</span> are
always invoked after each potential modification. Specifications need to
keep track themselves if an actual modification is made, if they wish to
make that distinction.

<p>An object implementing <code>URLUtils</code> has an associated
<dfn title=concept-UU-input>input</dfn> (a string),
<dfn title=concept-UU-query-encoding>query encoding</dfn>
Expand All @@ -1765,40 +1780,58 @@ <h2>API</h2>
<dfn title=concept-UU-url>url</dfn> (a
<span title=concept-parsed-url>parsed URL</span> or null).

Unless stated otherwise,
<span title=concept-UU-query-encoding>query encoding</span> is
<span data-anolis-spec=encoding>utf-8</span>, and
<span title=concept-UU-query-object>query object</span> and
<span title=concept-UU-url>url</span> are null. The others must be set on
creation by the specification using <code>URLUtils</code>.
Unless stated otherwise, <span title=concept-UU-query-encoding>query encoding</span> is
<span data-anolis-spec=encoding>utf-8</span>. The others follow from the
<span title=concept-UU-set-the-input>set the input</span> algorithm.

<p class=note>The associated
<span title=concept-UU-query-encoding>query encoding</span> is a legacy
concept only relevant for HTML.
<span data-anolis-ref class=informative>HTML</span>

<p>When an object implementing <code>URLUtils</code> is created with a
non-null <span title=concept-UU-url>url</span> whose
<span>relative flag</span> is set,
<span title=concept-UU-query-object>query object</span> must be set to a
<span title=concept-UQ-new>new <code>URLQuery</code> object</span> using
<span title=concept-UU-url>url</span>'s
<span title=concept-URL-query>query</span>.
<p>Specifications defining objects implementing <code>URLUtils</code> must use the
<span title=concept-UU-set-the-input>set the input</span> algorithms to set
<span title=concept-UU-input>input</span>, <span title=concept-UU-url>url</span>, and
<span title=concept-UU-query-object>query object</span>. To
<dfn title=concept-UU-set-the-input>set the input</dfn> run these steps:

<p>An object implementing <code>URLUtils</code> also has an associated
<dfn title=concept-UU-get-the-base>get the base</dfn> algorithm, which has to return the
appropriate <span title=concept-base-URL>base URL</span> for the object.
<ol>
<li><p>Set <span title=concept-UU-url>url</span> null.

<p>Specifications defining objects implementing <code>URLUtils</code> may
define <dfn title=concept-UU-update>update steps</dfn> to make it possible
for an underlying object (such as an
<span data-anolis-spec=dom title=concept-attribute-value>attribute value</span>)
to be updated.
<li><p>Set <span title=concept-UU-input>input</span> to the given value.

<p class=note>The <span title=concept-UU-update>update steps</span> are
always invoked after each potential modification. Specifications need to
keep track themselves if an actual modification is made, if they wish to
make that distinction.
<li><p>Let <var title>parsed URL</var> be the result of
<span title=concept-url-parser>parsing</span>
<span title=concept-UU-input>input</span> with
<span title=concept-base-url>base URL</span> being the result of running
<span title=concept-UU-get-the-base>get the base</span> and
<span title=concept-UU-query-encoding>query encoding</span> as
<var title>encoding override</var>.

<li><p>If <var title>parsed URL</var> is not failure, set
<span title=concept-UU-url>url</span> to <var title>parsed URL</var>.

<li>
<p>If <span title=concept-UU-url>url</span> is non-null and its
<span>relative flag</span> is set, run these substeps:

<ol>
<li><p>If <span title=concept-UU-query-object>query object</span> is null, set
<span title=concept-UU-query-object>query object</span> to a
<span title=concept-UQ-new>new <code>URLQuery</code> object</span> using
<span title=concept-UU-url>url</span>'s <span title=concept-URL-query>query</span>.

<li><p>Otherwise, set <span title=concept-UU-query-object>query object</span>'s
associated list of name-value pairs to the result of
<span title=concept-urlencoded-parser>parsing</span>
<span title=concept-UU-url>url</span>'s <span title=concept-URL-query>query</span>.
</ol>

<li><p>If <span title=concept-UU-url>url</span> is null and
<span title=concept-UU-query-object>query object</span> is non-null, empty
<span title=concept-UU-query-object>query object</span>'s associated list of name-value
pairs.
</ol>


<h3>Constructors</h3> <!-- "constructor" causes dfn.js to fail -->
Expand All @@ -1815,20 +1848,20 @@ <h3>Constructors</h3> <!-- "constructor" causes dfn.js to fail -->
<li><p>If <var title>base</var> is failure,
<span data-anolis-spec=dom title=concept-throw>throw</span> an
"<code data-anolis-spec=dom>SyntaxError</code>" exception.

<li><p>Let <var title>parsed URL</var> be the result of
<span title=concept-url-parser>parsing</span> <var title>url</var>
with <span title=concept-base-url>base URL</span> <var title>base</var>.

<li><p>If <var title>parsed URL</var> is failure,

<li><p>Let <var title>result</var> be a new <code>URL object</code>.

<li><p>Let <var title>result</var>'s
<span title=concept-UU-get-the-base>get the base</span> return <var title>base</var>.

<li><p>Run <var title>result</var>'s
<span title=concept-UU-set-the-input>set the input</span> for <var title>url</var>.

<li><p>If <var title>result</var>'s <span title=concept-UU-url>url</span> is null,
<span data-anolis-spec=dom title=concept-throw>throw</span> an
"<code data-anolis-spec=dom>SyntaxError</code>" exception.

<li><p>Create a new <code>URL</code> object, set its
<span title=concept-UU-url>url</span> to <var title>parsed URL</var>,
<span title=concept-UU-input>input</span> to <var title>url</var>, and make its
<span title=concept-UU-get-the-base>get the base</span> algorithm return
<var title>base</var>, and then return the new object.
<li><p>Return <var title>result</var>.
</ol>


Expand All @@ -1852,28 +1885,8 @@ <h3>Interface <code>URLUtils</code></h3>
run these steps:

<ol>
<li><p>Set <span title=concept-UU-url>url</span> and
<span title=concept-UU-query-object>query object</span> to null.

<li><p>Set <span title=concept-UU-input>input</span> to the given value.

<li><p>Let <var title>parsed URL</var> be the result of
<span title=concept-url-parser>parsing</span>
<span title=concept-UU-input>input</span> with
<span title=concept-base-url>base URL</span> being the result of running
<span title=concept-UU-get-the-base>get the base</span> and
<span title=concept-UU-query-encoding>query encoding</span> as
<var title>encoding override</var>.

<li><p>If <var title>parsed URL</var> is not failure, set
<span title=concept-UU-url>url</span> to <var title>parsed URL</var>.

<li><p>If <span title=concept-UU-url>url</span> is non-null and its
<span>relative flag</span> is set, set
<span title=concept-UU-query-object>query object</span> to a
<span title=concept-UQ-new>new <code>URLQuery</code> object</span> using
<span title=concept-UU-url>url</span>'s
<span title=concept-URL-query>query</span>.
<li><p>Run the <span title=concept-UU-set-the-input>set the input</span> algorithm for
the given value.

<li><p>Run the <span title=concept-UU-update>update steps</span>.
</ol>
Expand Down

0 comments on commit 4253baf

Please sign in to comment.