Home

# Library goog.uri.utils

Function Summary
| `appendKeyValuePairs_(string key, ?goog.uri.utils.QueryValue value, !Array pairs)` Appends key=value pairs to an array, supporting multi-valued objects.
| `appendParam(string uri, string key, <Any Type> value) ⇒ string` 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.

`appendParams(string uri, (goog.uri.utils.QueryArray|goog.uri.utils.QueryValue|null|string|undefined) var_args) ⇒ string`

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.

    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'

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.

| `appendParamsFromMap(string uri, ?Object map) ⇒ string` Appends query parameters from a map.
| `appendPath(string baseUri, string path) ⇒ string` 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.
| `appendQueryData_(!Array buffer) ⇒ string` Appends a URI and query data in a string buffer with special preconditions. Internal implementation utility, performing very few object allocations.
| `assertNoFragmentsOrQueries_(string uri)` Asserts that there are no fragment or query identifiers, only in uncompiled mode.
| `buildFromEncodedParts(?string= opt_scheme, ?string= opt_userInfo, ?string= opt_domain, (null|number|string=) opt_port, ?string= opt_path, ?string= opt_queryData, ?string= opt_fragment) ⇒ string` Builds a URI string from already-encoded parts. No encoding is performed. Any component may be omitted as either null or undefined.
| `buildQueryData(?goog.uri.utils.QueryArray keysAndValues, number= opt_startIndex) ⇒ string` Builds a query data string from a sequence of alternating keys and values. Currently generates "&key&" for empty args.
| `buildQueryDataBufferFromMap_(!Array buffer, ?Object map) ⇒ !Array` Builds a buffer of query data from a map.
| `buildQueryDataBuffer_(!Array buffer, (Arguments|goog.uri.utils.QueryArray|null) keysAndValues, number= opt_startIndex) ⇒ !Array` Builds a buffer of query data from a sequence of alternating keys and values.
| `buildQueryDataFromMap(?Object map) ⇒ string` Builds a query data string from a map. Currently generates "&key&" for empty args.
| `decodeIfPossible_(?string uri) ⇒ ?string`
| `findParam_(string uri, number startIndex, string keyEncoded, number hashOrEndIndex) ⇒ number` Finds the next instance of a query parameter with the specified name. Does not instantiate any objects.
| `getComponentByIndex_(?goog.uri.utils.ComponentIndex componentIndex, string uri) ⇒ ?string` Gets a URI component by index. It is preferred to use the getPathEncoded() variety of functions ahead, since they are more readable.
| `getDomain(string uri) ⇒ ?string`
| `getDomainEncoded(string uri) ⇒ ?string`
| `getEffectiveScheme(string uri) ⇒ string` Gets the effective scheme for the URL. If the URL is relative then the scheme is derived from the page's location.
| `getFragment(string uri) ⇒ ?string`
| `getFragmentEncoded(string uri) ⇒ ?string`
| `getHost(string uri) ⇒ string` Extracts everything up to the port of the URI.
| `getParamValue(string uri, string keyEncoded) ⇒ ?string` Gets the first value of a query parameter.
| `getParamValues(string uri, string keyEncoded) ⇒ !Array` Gets all values of a query parameter.
| `getPath(string uri) ⇒ ?string`
| `getPathAndAfter(string uri) ⇒ string` Extracts the path of the URL and everything after.
| `getPathEncoded(string uri) ⇒ ?string`
| `getPort(string uri) ⇒ ?number`
| `getQueryData(string uri) ⇒ ?string`
| `getScheme(string uri) ⇒ ?string`
| `getUserInfo(string uri) ⇒ ?string`
| `getUserInfoEncoded(string uri) ⇒ ?string`
| `hasParam(string uri, string keyEncoded) ⇒ boolean` Determines if the URI contains a specific key. Performs no object instantiations.
| `haveSameDomain(string uri1, string uri2) ⇒ boolean` 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.
| `makeUnique(string uri) ⇒ string` Sets the zx parameter of a URI to a random value.
| `removeFragment(string uri) ⇒ string` Gets the URI with the fragment identifier removed.
| `removeParam(string uri, string keyEncoded) ⇒ string` Removes all instances of a query parameter.
| `setFragmentEncoded(string uri, ?string fragment) ⇒ string`
| `setParam(string uri, string keyEncoded, <Any Type> value) ⇒ string` 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.

`split(string uri) ⇒ !Array`

Splits a URI into its component parts. Each component can be accessed via the component indices; for example:

    goog.uri.utils.split(someStr)[goog.uri.utils.CompontentIndex.QUERY_DATA];