You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
192 lines
52 KiB
192 lines
52 KiB
<!DOCTYPE html><meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>goog.uri.utils</title><link href="dossier.css" rel="stylesheet" type="text/css"><div id="main-wrapper"><input type="checkbox" id="sidenav-toggle" /><main><header><h1>Namespace goog.uri.utils</h1><a class="source" href="source/lib/goog/uri/utils.js.src.html#l48">code »</a></header><section></section><section><h2>Enumerations</h2><div class="type-summary"><table><tbody><tr><td><dl><dt><a href="enum_goog_uri_utils_CharCode_.html">goog.uri.utils.CharCode_</a><dd>Character codes inlined to avoid object allocations due to charCode.<dt><a href="enum_goog_uri_utils_ComponentIndex.html">goog.uri.utils.ComponentIndex</a><dd>The index of each URI component in the return value of goog.uri.utils.split.<dt><a href="enum_goog_uri_utils_StandardQueryParam.html">goog.uri.utils.StandardQueryParam</a><dd>Standard supported query parameters.</dl></table></div></section><div id="visibility-controls"><b>Show:</b><label for="show-public"><span><input type="checkbox" id="show-public" checked/></span>Public</label><label for="show-protected"><span><input type="checkbox" id="show-protected"/></span>Protected</label><label for="show-private"><span><input type="checkbox" id="show-private"/></span>Private</label></div><section id="typedefs"><h2>Type Definitions</h2><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l589">code »</a><a class="member" name="goog.uri.utils.QueryArray">goog.uri.utils.QueryArray</a> : <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code></div><div>An array representing a set of query parameters with alternating keys
|
|
and values.
|
|
|
|
Keys are assumed to be URI encoded already and live at even indices. See
|
|
goog.uri.utils.QueryValue for details on how parameter values are encoded.
|
|
|
|
Example:
|
|
<pre>
|
|
var data = [
|
|
// Simple param: ?name=BobBarker
|
|
'name', 'BobBarker',
|
|
// Conditional param -- may be omitted entirely.
|
|
'specialDietaryNeeds', hasDietaryNeeds() ? getDietaryNeeds() : null,
|
|
// Multi-valued param: &house=LosAngeles&house=NewYork&house=null
|
|
'house', ['LosAngeles', 'NewYork', null]
|
|
];
|
|
</pre></div></summary></details></div></div><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l565">code »</a><a class="member" name="goog.uri.utils.QueryValue">goog.uri.utils.QueryValue</a> : <code class="type">*</code></div><div>Supported query parameter values by the parameter serializing utilities.
|
|
|
|
If a value is null or undefined, the key-value pair is skipped, as an easy
|
|
way to omit parameters conditionally. Non-array parameters are converted
|
|
to a string and URI encoded. Array values are expanded into multiple
|
|
&key=value pairs, with each element stringized and URI-encoded.</div></summary></details></div></div></section><section id="static-functions"><h2>Global Functions</h2><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l640">code »</a><span class="member"><a name="goog.uri.utils.appendKeyValuePairs_">goog.uri.utils.appendKeyValuePairs_</a> <span class="args">( key, value, pairs )</span></span></div><p>Appends key=value pairs to an array, supporting multi-valued objects.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>key: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The key prefix.<dt>value: <code class="type"><a href="namespace_goog_uri_utils.html#goog.uri.utils.QueryValue">goog.uri.utils.QueryValue</a></code><dd>The value to serialize.<dt>pairs: <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a>.<<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code><dd>The array to which the 'key=value' strings
|
|
should be appended.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l804">code »</a><span class="member"><a name="goog.uri.utils.appendParam">goog.uri.utils.appendParam</a> <span class="args">( uri, key, opt_value )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Appends a single URI parameter.
|
|
|
|
Repeated calls to this can exhibit quadratic behavior in IE6 due to the
|
|
way string append works, though it should be limited given the 2kb limit.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The original URI, which may already have query data.<dt>key: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The key, which must already be URI encoded.<dt>opt_value: <code class="type">*=</code><dd>The value, which will be stringized and encoded
|
|
(assumed not already to be encoded). If omitted, undefined, or null, the
|
|
key will be added as a valueless parameter.</dl><tr><th>Returns<tr><td><dl>The URI with the query parameter added.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l768">code »</a><span class="member"><a name="goog.uri.utils.appendParams">goog.uri.utils.appendParams</a> <span class="args">( uri, var_args )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Appends URI parameters to an existing URI.
|
|
|
|
The variable arguments may contain alternating keys and values. Keys are
|
|
assumed to be already URI encoded. The values should not be URI-encoded,
|
|
and will instead be encoded by this function.
|
|
<pre>
|
|
appendParams('http://www.foo.com?existing=true',
|
|
'key1', 'value1',
|
|
'key2', 'value?willBeEncoded',
|
|
'key3', ['valueA', 'valueB', 'valueC'],
|
|
'key4', null);
|
|
result: 'http://www.foo.com?existing=true&' +
|
|
'key1=value1&' +
|
|
'key2=value%3FwillBeEncoded&' +
|
|
'key3=valueA&key3=valueB&key3=valueC'
|
|
</pre>
|
|
|
|
A single call to this function will not exhibit quadratic behavior in IE,
|
|
whereas multiple repeated calls may, although the effect is limited by
|
|
fact that URL's generally can't exceed 2kb.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The original URI, which may already have query data.<dt>var_args: <code class="type">...(<a href="namespace_goog_uri_utils.html#goog.uri.utils.QueryArray">goog.uri.utils.QueryArray</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="namespace_goog_uri_utils.html#goog.uri.utils.QueryValue">goog.uri.utils.QueryValue</a>)</code><dd>An array or argument list conforming to goog.uri.utils.QueryArray.</dl><tr><th>Returns<tr><td><dl>The URI with all query parameters added.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l785">code »</a><span class="member"><a name="goog.uri.utils.appendParamsFromMap">goog.uri.utils.appendParamsFromMap</a> <span class="args">( uri, map )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Appends query parameters from a map.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The original URI, which may already have query data.<dt>map: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>An object where keys are URI-encoded parameter keys,
|
|
and the values are arbitrary types or arrays. Keys with a null value
|
|
are dropped.</dl><tr><th>Returns<tr><td><dl>The new parameters.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l1018">code »</a><span class="member"><a name="goog.uri.utils.appendPath">goog.uri.utils.appendPath</a> <span class="args">( baseUri, path )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Generates a URI path using a given URI and a path with checks to
|
|
prevent consecutive "//". The baseUri passed in must not contain
|
|
query or fragment identifiers. The path to append may not contain query or
|
|
fragment identifiers.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>baseUri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>URI to use as the base.<dt>path: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>Path to append.</dl><tr><th>Returns<tr><td><dl>Updated URI.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l605">code »</a><span class="member"><a name="goog.uri.utils.appendQueryData_">goog.uri.utils.appendQueryData_</a> <span class="args">( buffer )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Appends a URI and query data in a string buffer with special preconditions.
|
|
|
|
Internal implementation utility, performing very few object allocations.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>buffer: <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code><dd>A string buffer. The first element
|
|
must be the base URI, and may have a fragment identifier. If the array
|
|
contains more than one element, the second element must be an ampersand,
|
|
and may be overwritten, depending on the base URI. Undefined elements
|
|
are treated as empty-string.</dl><tr><th>Returns<tr><td><dl>The concatenated URI and query data.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l545">code »</a><span class="member"><a name="goog.uri.utils.assertNoFragmentsOrQueries_">goog.uri.utils.assertNoFragmentsOrQueries_</a> <span class="args">( uri )</span></span></div><p>Asserts that there are no fragment or query identifiers, only in uncompiled
|
|
mode.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l89">code »</a><span class="member"><a name="goog.uri.utils.buildFromEncodedParts">goog.uri.utils.buildFromEncodedParts</a> <span class="args">( opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Builds a URI string from already-encoded parts.
|
|
|
|
No encoding is performed. Any component may be omitted as either null or
|
|
undefined.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>opt_scheme: <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>The scheme such as 'http'.<dt>opt_userInfo: <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>The user name before the '@'.<dt>opt_domain: <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>The domain such as 'www.google.com', already
|
|
URI-encoded.<dt>opt_port: <code class="type">(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>|<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Null">null</a>)=</code><dd>The port number.<dt>opt_path: <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>The path, already URI-encoded. If it is not
|
|
empty, it must begin with a slash.<dt>opt_queryData: <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>The URI-encoded query data.<dt>opt_fragment: <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>The URI-encoded fragment identifier.</dl><tr><th>Returns<tr><td><dl>The fully combined URI.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l697">code »</a><span class="member"><a name="goog.uri.utils.buildQueryData">goog.uri.utils.buildQueryData</a> <span class="args">( keysAndValues, opt_startIndex )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Builds a query data string from a sequence of alternating keys and values.
|
|
Currently generates "&key&" for empty args.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>keysAndValues: <code class="type"><a href="namespace_goog_uri_utils.html#goog.uri.utils.QueryArray">goog.uri.utils.QueryArray</a></code><dd>Alternating keys and
|
|
values. See the typedef.<dt>opt_startIndex: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>A start offset into the arary, defaults to 0.</dl><tr><th>Returns<tr><td><dl>The encoded query string, in the form 'a=1&b=2'.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l716">code »</a><span class="member"><a name="goog.uri.utils.buildQueryDataBufferFromMap_">goog.uri.utils.buildQueryDataBufferFromMap_</a> <span class="args">( buffer, map )</span> ⇒ <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code></span></div><p>Builds a buffer of query data from a map.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>buffer: <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code><dd>A string buffer to append to. The
|
|
first element appended will be an '&', and may be replaced by the caller.<dt>map: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>.<<a href="namespace_goog_uri_utils.html#goog.uri.utils.QueryValue">goog.uri.utils.QueryValue</a>></code><dd>An object where keys are
|
|
URI-encoded parameter keys, and the values conform to the contract
|
|
specified in the goog.uri.utils.QueryValue typedef.</dl><tr><th>Returns<tr><td><dl>The buffer argument.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l674">code »</a><span class="member"><a name="goog.uri.utils.buildQueryDataBuffer_">goog.uri.utils.buildQueryDataBuffer_</a> <span class="args">( buffer, keysAndValues, opt_startIndex )</span> ⇒ <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code></span></div><p>Builds a buffer of query data from a sequence of alternating keys and values.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>buffer: <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code><dd>A string buffer to append to. The
|
|
first element appended will be an '&', and may be replaced by the caller.<dt>keysAndValues: <code class="type">(<a href="namespace_goog_uri_utils.html#goog.uri.utils.QueryArray">goog.uri.utils.QueryArray</a>|<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Functions_and_function_scope/arguments">Arguments</a>)</code><dd>An array with
|
|
alternating keys and values -- see the typedef.<dt>opt_startIndex: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>A start offset into the arary, defaults to 0.</dl><tr><th>Returns<tr><td><dl>The buffer argument.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l734">code »</a><span class="member"><a name="goog.uri.utils.buildQueryDataFromMap">goog.uri.utils.buildQueryDataFromMap</a> <span class="args">( map )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Builds a query data string from a map.
|
|
Currently generates "&key&" for empty args.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>map: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>An object where keys are URI-encoded parameter keys,
|
|
and the values are arbitrary types or arrays. Keys with a null value
|
|
are dropped.</dl><tr><th>Returns<tr><td><dl>The encoded query string, in the form 'a=1&b=2'.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l304">code »</a><span class="member"><a name="goog.uri.utils.decodeIfPossible_">goog.uri.utils.decodeIfPossible_</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>A possibly null string.</dl><tr><th>Returns<tr><td><dl>The string URI-decoded, or null if uri is null.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l830">code »</a><span class="member"><a name="goog.uri.utils.findParam_">goog.uri.utils.findParam_</a> <span class="args">( uri, startIndex, keyEncoded, hashOrEndIndex )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Finds the next instance of a query parameter with the specified name.
|
|
|
|
Does not instantiate any objects.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to search. May contain a fragment identifier
|
|
if opt_hashIndex is specified.<dt>startIndex: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The index to begin searching for the key at. A
|
|
match may be found even if this is one character after the ampersand.<dt>keyEncoded: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI-encoded key.<dt>hashOrEndIndex: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>Index to stop looking at. If a hash
|
|
mark is present, it should be its index, otherwise it should be the
|
|
length of the string.</dl><tr><th>Returns<tr><td><dl>The position of the first character in the key's name,
|
|
immediately after either a question mark or a dot.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l321">code »</a><span class="member"><a name="goog.uri.utils.getComponentByIndex_">goog.uri.utils.getComponentByIndex_</a> <span class="args">( componentIndex, uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Gets a URI component by index.
|
|
|
|
It is preferred to use the getPathEncoded() variety of functions ahead,
|
|
since they are more readable.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>componentIndex: <code class="type"><a href="enum_goog_uri_utils_ComponentIndex.html">goog.uri.utils.ComponentIndex</a></code><dd>The component index.<dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The still-encoded component, or null if the component
|
|
is not present.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l390">code »</a><span class="member"><a name="goog.uri.utils.getDomain">goog.uri.utils.getDomain</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The decoded domain, or null if none.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l380">code »</a><span class="member"><a name="goog.uri.utils.getDomainEncoded">goog.uri.utils.getDomainEncoded</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The domain name still encoded, or null if none.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l344">code »</a><span class="member"><a name="goog.uri.utils.getEffectiveScheme">goog.uri.utils.getEffectiveScheme</a> <span class="args">( uri )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Gets the effective scheme for the URL. If the URL is relative then the
|
|
scheme is derived from the page's location.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The protocol or scheme, always lower case.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l469">code »</a><span class="member"><a name="goog.uri.utils.getFragment">goog.uri.utils.getFragment</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The decoded fragment identifier, or null if none. Does
|
|
not include the hash mark.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l446">code »</a><span class="member"><a name="goog.uri.utils.getFragmentEncoded">goog.uri.utils.getFragmentEncoded</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The fragment identifier, or null if none. Does not
|
|
include the hash mark itself.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l480">code »</a><span class="member"><a name="goog.uri.utils.getHost">goog.uri.utils.getHost</a> <span class="args">( uri )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Extracts everything up to the port of the URI.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI string.</dl><tr><th>Returns<tr><td><dl>Everything up to and including the port.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l891">code »</a><span class="member"><a name="goog.uri.utils.getParamValue">goog.uri.utils.getParamValue</a> <span class="args">( uri, keyEncoded )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Gets the first value of a query parameter.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to process. May contain a fragment.<dt>keyEncoded: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI-encoded key. Case-sensitive.</dl><tr><th>Returns<tr><td><dl>The first value of the parameter (URI-decoded), or null
|
|
if the parameter is not found.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l920">code »</a><span class="member"><a name="goog.uri.utils.getParamValues">goog.uri.utils.getParamValues</a> <span class="args">( uri, keyEncoded )</span> ⇒ <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a>.<<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code></span></div><p>Gets all values of a query parameter.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to process. May contain a framgnet.<dt>keyEncoded: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI-encoded key. Case-snsitive.</dl><tr><th>Returns<tr><td><dl>All URI-decoded values with the given key.
|
|
If the key is not found, this will have length 0, but never be null.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l425">code »</a><span class="member"><a name="goog.uri.utils.getPath">goog.uri.utils.getPath</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The decoded path, or null if none. Includes the leading
|
|
slash, if any.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l496">code »</a><span class="member"><a name="goog.uri.utils.getPathAndAfter">goog.uri.utils.getPathAndAfter</a> <span class="args">( uri )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Extracts the path of the URL and everything after.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI string.</dl><tr><th>Returns<tr><td><dl>The URI, starting at the path and including the query
|
|
parameters and fragment identifier.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l414">code »</a><span class="member"><a name="goog.uri.utils.getPathEncoded">goog.uri.utils.getPathEncoded</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The path still encoded, or null if none. Includes the
|
|
leading slash, if any.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l399">code »</a><span class="member"><a name="goog.uri.utils.getPort">goog.uri.utils.getPort</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The port number, or null if none.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l435">code »</a><span class="member"><a name="goog.uri.utils.getQueryData">goog.uri.utils.getQueryData</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The query data still encoded, or null if none. Does not
|
|
include the question mark itself.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l332">code »</a><span class="member"><a name="goog.uri.utils.getScheme">goog.uri.utils.getScheme</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The protocol or scheme, or null if none. Does not
|
|
include trailing colons or slashes.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l370">code »</a><span class="member"><a name="goog.uri.utils.getUserInfo">goog.uri.utils.getUserInfo</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The decoded user info, or null if none.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l360">code »</a><span class="member"><a name="goog.uri.utils.getUserInfoEncoded">goog.uri.utils.getUserInfoEncoded</a> <span class="args">( uri )</span> ⇒ <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>The user name still encoded, or null if none.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l878">code »</a><span class="member"><a name="goog.uri.utils.hasParam">goog.uri.utils.hasParam</a> <span class="args">( uri, keyEncoded )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Determines if the URI contains a specific key.
|
|
|
|
Performs no object instantiations.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to process. May contain a fragment
|
|
identifier.<dt>keyEncoded: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI-encoded key. Case-sensitive.</dl><tr><th>Returns<tr><td><dl>Whether the key is present.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l527">code »</a><span class="member"><a name="goog.uri.utils.haveSameDomain">goog.uri.utils.haveSameDomain</a> <span class="args">( uri1, uri2 )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Ensures that two URI's have the exact same domain, scheme, and port.
|
|
|
|
Unlike the version in goog.Uri, this checks protocol, and therefore is
|
|
suitable for checking against the browser's same-origin policy.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri1: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The first URI.<dt>uri2: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The second URI.</dl><tr><th>Returns<tr><td><dl>Whether they have the same domain and port.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l1073">code »</a><span class="member"><a name="goog.uri.utils.makeUnique">goog.uri.utils.makeUnique</a> <span class="args">( uri )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Sets the zx parameter of a URI to a random value.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>Any URI.</dl><tr><th>Returns<tr><td><dl>That URI with the "zx" parameter added or replaced to
|
|
contain a random string.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l277">code »</a><span class="member"><a name="goog.uri.utils.phishingProtection_">goog.uri.utils.phishingProtection_</a> <span class="args">( )</span></span></div><p>Check to see if the user is being phished.</summary></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l510">code »</a><span class="member"><a name="goog.uri.utils.removeFragment">goog.uri.utils.removeFragment</a> <span class="args">( uri )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Gets the URI with the fragment identifier removed.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.</dl><tr><th>Returns<tr><td><dl>Everything preceding the hash mark.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l961">code »</a><span class="member"><a name="goog.uri.utils.removeParam">goog.uri.utils.removeParam</a> <span class="args">( uri, keyEncoded )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Removes all instances of a query parameter.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to process. Must not contain a fragment.<dt>keyEncoded: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI-encoded key.</dl><tr><th>Returns<tr><td><dl>The URI with all instances of the parameter removed.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l459">code »</a><span class="member"><a name="goog.uri.utils.setFragmentEncoded">goog.uri.utils.setFragmentEncoded</a> <span class="args">( uri, fragment )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI to examine.<dt>fragment: <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The encoded fragment identifier, or null if none.
|
|
Does not include the hash mark itself.</dl><tr><th>Returns<tr><td><dl>The URI with the fragment set.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l1002">code »</a><span class="member"><a name="goog.uri.utils.setParam">goog.uri.utils.setParam</a> <span class="args">( uri, keyEncoded, value )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Replaces all existing definitions of a parameter with a single definition.
|
|
|
|
Repeated calls to this can exhibit quadratic behavior due to the need to
|
|
find existing instances and reconstruct the string, though it should be
|
|
limited given the 2kb limit. Consider using appendParams to append multiple
|
|
parameters in bulk.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The original URI, which may already have query data.<dt>keyEncoded: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The key, which must already be URI encoded.<dt>value: <code class="type">*</code><dd>The value, which will be stringized and encoded (assumed
|
|
not already to be encoded).</dl><tr><th>Returns<tr><td><dl>The URI with the query parameter added.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l1039">code »</a><span class="member"><a name="goog.uri.utils.setPath">goog.uri.utils.setPath</a> <span class="args">( uri, path )</span> ⇒ <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Replaces the path.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>URI to use as the base.<dt>path: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>New path.</dl><tr><th>Returns<tr><td><dl>Updated URI.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l238">code »</a><span class="member"><a name="goog.uri.utils.split">goog.uri.utils.split</a> <span class="args">( uri )</span> ⇒ <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code></span></div><p>Splits a URI into its component parts.
|
|
|
|
Each component can be accessed via the component indices; for example:
|
|
<pre>
|
|
goog.uri.utils.split(someStr)[goog.uri.utils.CompontentIndex.QUERY_DATA];
|
|
</pre></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>uri: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The URI string to examine.</dl><tr><th>Returns<tr><td><dl>Each component still URI-encoded.
|
|
Each component that is present will contain the encoded value, whereas
|
|
components that are not present will be undefined or empty, depending
|
|
on the browser's regular expression implementation. Never null, since
|
|
arbitrary strings may still look like path names.</dl></table></div></details></div></div></section><section id="static-properties"><h2>Global Properties</h2><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l865">code »</a><span class="member"><a name="goog.uri.utils.hashOrEndRe_">goog.uri.utils.hashOrEndRe_</a> : <code class="type"><a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/RegExp">RegExp</a></code></span></div><p>Regular expression for finding a hash mark or end of string.</summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l270">code »</a><span class="member"><a name="goog.uri.utils.needsPhishingProtection_">goog.uri.utils.needsPhishingProtection_</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Safari has a nasty bug where if you have an http URL with a username, e.g.,
|
|
http://evil.com%2F@google.com/
|
|
Safari will report that window.location.href is
|
|
http://evil.com/google.com/
|
|
so that anyone who tries to parse the domain of that URL will get
|
|
the wrong domain. We've seen exploits where people use this to trick
|
|
Safari into loading resources from evil domains.
|
|
|
|
To work around this, we run a little "Safari phishing check", and throw
|
|
an exception if we see this happening.
|
|
|
|
There is no convenient place to put this check. We apply it to
|
|
anyone doing URI parsing on Webkit. We're not happy about this, but
|
|
it fixes the problem.
|
|
|
|
This should be removed once Safari fixes their bug.
|
|
|
|
Exploit reported by Masato Kinugawa.</summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l189">code »</a><span class="member"><a name="goog.uri.utils.splitRe_">goog.uri.utils.splitRe_</a> : <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/RegExp">RegExp</a></code></span></div><p>A regular expression for breaking a URI into its component parts.
|
|
|
|
<code class="type"><a class="unresolved-link">http://www.ietf.org/rfc/rfc3986.txt</a></code> says in Appendix B
|
|
As the "first-match-wins" algorithm is identical to the "greedy"
|
|
disambiguation method used by POSIX regular expressions, it is natural and
|
|
commonplace to use a regular expression for parsing the potential five
|
|
components of a URI reference.
|
|
|
|
The following line is the regular expression for breaking-down a
|
|
well-formed URI reference into its components.
|
|
|
|
<pre>
|
|
^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
|
|
12 3 4 5 6 7 8 9
|
|
</pre>
|
|
|
|
The numbers in the second line above are only to assist readability; they
|
|
indicate the reference points for each subexpression (i.e., each paired
|
|
parenthesis). We refer to the value matched for subexpression <n> as $<n>.
|
|
For example, matching the above expression to
|
|
<pre>
|
|
http://www.ics.uci.edu/pub/ietf/uri/#Related
|
|
</pre>
|
|
results in the following subexpression matches:
|
|
<pre>
|
|
$1 = http:
|
|
$2 = http
|
|
$3 = //www.ics.uci.edu
|
|
$4 = www.ics.uci.edu
|
|
$5 = /pub/ietf/uri/
|
|
$6 = <undefined>
|
|
$7 = <undefined>
|
|
$8 = #Related
|
|
$9 = Related
|
|
</pre>
|
|
where <undefined> indicates that the component is not present, as is the
|
|
case for the query component in the above example. Therefore, we can
|
|
determine the value of the five components as
|
|
<pre>
|
|
scheme = $2
|
|
authority = $4
|
|
path = $5
|
|
query = $7
|
|
fragment = $9
|
|
</pre>
|
|
|
|
The regular expression has been modified slightly to expose the
|
|
userInfo, domain, and port separately from the authority.
|
|
The modified version yields
|
|
<pre>
|
|
$1 = http scheme
|
|
$2 = <undefined> userInfo -\
|
|
$3 = www.ics.uci.edu domain | authority
|
|
$4 = <undefined> port -/
|
|
$5 = /pub/ietf/uri/ path
|
|
$6 = <undefined> query without ?
|
|
$7 = Related fragment without #
|
|
</pre></summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/goog/uri/utils.js.src.html#l952">code »</a><span class="member"><a name="goog.uri.utils.trailingQueryPunctuationRe_">goog.uri.utils.trailingQueryPunctuationRe_</a> : <code class="type"><a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/RegExp">RegExp</a></code></span></div><p>Regexp to find trailing question marks and ampersands.</summary></details></div></div></section></main><nav id="topnav"><div><div id="menubutton"><label for="sidenav-toggle">Menu</label></div><form id="searchbox"><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></nav><nav id="sidenav"><input type="checkbox" id="sidenav-types-ctrl" /><input type="checkbox" id="sidenav-files-ctrl" /><input type="checkbox" id="sidenav-modules-ctrl" /><a id="sidenav-overview"><div><h4>Overview</h4></div></a><div id="sidenav-types"><label for="sidenav-types-ctrl"><h4>Types</h4></label><i>No data</i></div><div id="sidenav-modules"><label for="sidenav-modules-ctrl"><h4>Modules</h4></label><i>No data</i></div><div id="sidenav-files"><label for="sidenav-files-ctrl"><h4>Files</h4></label><i>No data</i></div><a href="license.html"><div><h4>License</h4></div></a></nav><div id="push-footer"></div></div><footer><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></footer><script src="types.js"></script><script src="dossier.js"></script> |