utils.js
No description.

File Location

/goog/uri/utils.js


Public Protected Private

Enumerations

Global Functions

goog.uri.utils.appendKeyValuePairs_(keyvaluepairs)
Appends key=value pairs to an array, supporting multi-valued objects.
Arguments:
key : string
The key prefix.
value : goog.uri.utils.QueryValue
The value to serialize.
pairs : !Array.<string>
The array to which the 'key=value' strings should be appended.
code »
goog.uri.utils.appendParam(urikeyopt_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.
Arguments:
uri : string
The original URI, which may already have query data.
key : string
The key, which must already be URI encoded.
opt_value : *=
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.
Returns: string  The URI with the query parameter added.
code »
goog.uri.utils.appendParams(urivar_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.
Arguments:
uri : string
The original URI, which may already have query data.
var_args : ...(goog.uri.utils.QueryArray | string | goog.uri.utils.QueryValue)
An array or argument list conforming to goog.uri.utils.QueryArray.
Returns: string  The URI with all query parameters added.
code »
goog.uri.utils.appendParamsFromMap(urimap) string
Appends query parameters from a map.
Arguments:
uri : string
The original URI, which may already have query data.
map : Object
An object where keys are URI-encoded parameter keys, and the values are arbitrary types or arrays. Keys with a null value are dropped.
Returns: string  The new parameters.
code »
goog.uri.utils.appendPath(baseUripath) 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.
Arguments:
baseUri : string
URI to use as the base.
path : string
Path to append.
Returns: string  Updated URI.
code »
goog.uri.utils.appendQueryData_(buffer) string
Appends a URI and query data in a string buffer with special preconditions. Internal implementation utility, performing very few object allocations.
Arguments:
buffer : !Array.<string | undefined>
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.
Returns: string  The concatenated URI and query data.
code »
goog.uri.utils.assertNoFragmentsOrQueries_(uri)
Asserts that there are no fragment or query identifiers, only in uncompiled mode.
Arguments:
uri : string
The URI to examine.
code »
goog.uri.utils.buildFromEncodedParts(opt_schemeopt_userInfoopt_domainopt_portopt_pathopt_queryDataopt_fragment) string
Builds a URI string from already-encoded parts. No encoding is performed. Any component may be omitted as either null or undefined.
Arguments:
opt_scheme : ?string=
The scheme such as 'http'.
opt_userInfo : ?string=
The user name before the '@'.
opt_domain : ?string=
The domain such as 'www.google.com', already URI-encoded.
opt_port : (string | number | null)=
The port number.
opt_path : ?string=
The path, already URI-encoded. If it is not empty, it must begin with a slash.
opt_queryData : ?string=
The URI-encoded query data.
opt_fragment : ?string=
The URI-encoded fragment identifier.
Returns: string  The fully combined URI.
code »
goog.uri.utils.buildQueryData(keysAndValuesopt_startIndex) string
Builds a query data string from a sequence of alternating keys and values. Currently generates "&key&" for empty args.
Arguments:
keysAndValues : goog.uri.utils.QueryArray
Alternating keys and values. See the typedef.
opt_startIndex : number=
A start offset into the arary, defaults to 0.
Returns: string  The encoded query string, in the form 'a=1&b=2'.
code »
goog.uri.utils.buildQueryDataBufferFromMap_(buffermap) !Array.<string | undefined>
Builds a buffer of query data from a map.
Arguments:
buffer : !Array.<string | undefined>
A string buffer to append to. The first element appended will be an '&', and may be replaced by the caller.
map : Object.<goog.uri.utils.QueryValue>
An object where keys are URI-encoded parameter keys, and the values conform to the contract specified in the goog.uri.utils.QueryValue typedef.
Returns: !Array.<string | undefined>  The buffer argument.
code »
goog.uri.utils.buildQueryDataBuffer_(bufferkeysAndValuesopt_startIndex) !Array.<string | undefined>
Builds a buffer of query data from a sequence of alternating keys and values.
Arguments:
buffer : !Array.<string | undefined>
A string buffer to append to. The first element appended will be an '&', and may be replaced by the caller.
keysAndValues : goog.uri.utils.QueryArray | Arguments
An array with alternating keys and values -- see the typedef.
opt_startIndex : number=
A start offset into the arary, defaults to 0.
Returns: !Array.<string | undefined>  The buffer argument.
code »
goog.uri.utils.buildQueryDataFromMap(map) string
Builds a query data string from a map. Currently generates "&key&" for empty args.
Arguments:
map : Object
An object where keys are URI-encoded parameter keys, and the values are arbitrary types or arrays. Keys with a null value are dropped.
Returns: string  The encoded query string, in the form 'a=1&b=2'.
code »
goog.uri.utils.decodeIfPossible_(uri) ?string
No description.
Arguments:
uri : ?string
A possibly null string.
Returns: ?string  The string URI-decoded, or null if uri is null.
code »
goog.uri.utils.findParam_(uristartIndexkeyEncodedhashOrEndIndex) number
Finds the next instance of a query parameter with the specified name. Does not instantiate any objects.
Arguments:
uri : string
The URI to search. May contain a fragment identifier if opt_hashIndex is specified.
startIndex : number
The index to begin searching for the key at. A match may be found even if this is one character after the ampersand.
keyEncoded : string
The URI-encoded key.
hashOrEndIndex : number
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.
Returns: number  The position of the first character in the key's name, immediately after either a question mark or a dot.
code »
goog.uri.utils.getComponentByIndex_(componentIndexuri) ?string
Gets a URI component by index. It is preferred to use the getPathEncoded() variety of functions ahead, since they are more readable.
Arguments:
componentIndex : goog.uri.utils.ComponentIndex
The component index.
uri : string
The URI to examine.
Returns: ?string  The still-encoded component, or null if the component is not present.
code »
goog.uri.utils.getDomain(uri) ?string
No description.
Arguments:
uri : string
The URI to examine.
Returns: ?string  The decoded domain, or null if none.
code »
goog.uri.utils.getDomainEncoded(uri) ?string
No description.
Arguments:
uri : string
The URI to examine.
Returns: ?string  The domain name still encoded, or null if none.
code »
goog.uri.utils.getEffectiveScheme(uri) string
Gets the effective scheme for the URL. If the URL is relative then the scheme is derived from the page's location.
Arguments:
uri : string
The URI to examine.
Returns: string  The protocol or scheme, always lower case.
code »
goog.uri.utils.getFragment(uri) ?string
No description.
Arguments:
uri : string
The URI to examine.
Returns: ?string  The decoded fragment identifier, or null if none. Does not include the hash mark.
code »
goog.uri.utils.getFragmentEncoded(uri) ?string
No description.
Arguments:
uri : string
The URI to examine.
Returns: ?string  The fragment identifier, or null if none. Does not include the hash mark itself.
code »
goog.uri.utils.getHost(uri) string
Extracts everything up to the port of the URI.
Arguments:
uri : string
The URI string.
Returns: string  Everything up to and including the port.
code »
goog.uri.utils.getParamValue(urikeyEncoded) ?string
Gets the first value of a query parameter.
Arguments:
uri : string
The URI to process. May contain a fragment.
keyEncoded : string
The URI-encoded key. Case-sensitive.
Returns: ?string  The first value of the parameter (URI-decoded), or null if the parameter is not found.
code »
goog.uri.utils.getParamValues(urikeyEncoded) !Array.<string>
Gets all values of a query parameter.
Arguments:
uri : string
The URI to process. May contain a framgnet.
keyEncoded : string
The URI-encoded key. Case-snsitive.
Returns: !Array.<string>  All URI-decoded values with the given key. If the key is not found, this will have length 0, but never be null.
code »
goog.uri.utils.getPath(uri) ?string
No description.
Arguments:
uri : string
The URI to examine.
Returns: ?string  The decoded path, or null if none. Includes the leading slash, if any.
code »
goog.uri.utils.getPathAndAfter(uri) string
Extracts the path of the URL and everything after.
Arguments:
uri : string
The URI string.
Returns: string  The URI, starting at the path and including the query parameters and fragment identifier.
code »
goog.uri.utils.getPathEncoded(uri) ?string
No description.
Arguments:
uri : string
The URI to examine.
Returns: ?string  The path still encoded, or null if none. Includes the leading slash, if any.
code »
goog.uri.utils.getPort(uri) ?number
No description.
Arguments:
uri : string
The URI to examine.
Returns: ?number  The port number, or null if none.
code »
goog.uri.utils.getQueryData(uri) ?string
No description.
Arguments:
uri : string
The URI to examine.
Returns: ?string  The query data still encoded, or null if none. Does not include the question mark itself.
code »
goog.uri.utils.getScheme(uri) ?string
No description.
Arguments:
uri : string
The URI to examine.
Returns: ?string  The protocol or scheme, or null if none. Does not include trailing colons or slashes.
code »
goog.uri.utils.getUserInfo(uri) ?string
No description.
Arguments:
uri : string
The URI to examine.
Returns: ?string  The decoded user info, or null if none.
code »
goog.uri.utils.getUserInfoEncoded(uri) ?string
No description.
Arguments:
uri : string
The URI to examine.
Returns: ?string  The user name still encoded, or null if none.
code »
goog.uri.utils.hasParam(urikeyEncoded) boolean
Determines if the URI contains a specific key. Performs no object instantiations.
Arguments:
uri : string
The URI to process. May contain a fragment identifier.
keyEncoded : string
The URI-encoded key. Case-sensitive.
Returns: boolean  Whether the key is present.
code »
goog.uri.utils.haveSameDomain(uri1uri2) 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.
Arguments:
uri1 : string
The first URI.
uri2 : string
The second URI.
Returns: boolean  Whether they have the same domain and port.
code »
goog.uri.utils.makeUnique(uri) string
Sets the zx parameter of a URI to a random value.
Arguments:
uri : string
Any URI.
Returns: string  That URI with the "zx" parameter added or replaced to contain a random string.
code »
goog.uri.utils.phishingProtection_()
Check to see if the user is being phished.
code »
goog.uri.utils.removeFragment(uri) string
Gets the URI with the fragment identifier removed.
Arguments:
uri : string
The URI to examine.
Returns: string  Everything preceding the hash mark.
code »
goog.uri.utils.removeParam(urikeyEncoded) string
Removes all instances of a query parameter.
Arguments:
uri : string
The URI to process. Must not contain a fragment.
keyEncoded : string
The URI-encoded key.
Returns: string  The URI with all instances of the parameter removed.
code »
goog.uri.utils.setFragmentEncoded(urifragment) string
No description.
Arguments:
uri : string
The URI to examine.
fragment : ?string
The encoded fragment identifier, or null if none. Does not include the hash mark itself.
Returns: string  The URI with the fragment set.
code »
goog.uri.utils.setParam(urikeyEncodedvalue) 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.
Arguments:
uri : string
The original URI, which may already have query data.
keyEncoded : string
The key, which must already be URI encoded.
value : *
The value, which will be stringized and encoded (assumed not already to be encoded).
Returns: string  The URI with the query parameter added.
code »
goog.uri.utils.setPath(uripath) string
Replaces the path.
Arguments:
uri : string
URI to use as the base.
path : string
New path.
Returns: string  Updated URI.
code »
goog.uri.utils.split(uri) !Array.<string | undefined>
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];
Arguments:
uri : string
The URI string to examine.
Returns: !Array.<string | undefined>  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.
code »

Global Variables

function%122 :
No description.
Code »
function%123 :
No description.
Code »
function%124 :
No description.
Code »
function%125 :
No description.
Code »
function%126 :
No description.
Code »
function%127 :
No description.
Code »
function%128 :
No description.
Code »
function%129 :
No description.
Code »
function%130 :
No description.
Code »
function%131 :
No description.
Code »
function%132 :
No description.
Code »
function%133 :
No description.
Code »
function%134 :
No description.
Code »
function%135 :
No description.
Code »
function%136 :
No description.
Code »
function%137 :
No description.
Code »
function%138 :
No description.
Code »
function%139 :
No description.
Code »
function%140 :
No description.
Code »
function%141 :
No description.
Code »
function%142 :
No description.
Code »
function%143 :
No description.
Code »
function%144 :
No description.
Code »
function%145 :
No description.
Code »
function%146 :
No description.
Code »
function%147 :
No description.
Code »
function%148 :
No description.
Code »
function%149 :
No description.
Code »
function%150 :
No description.
Code »
function%151 :
No description.
Code »
function%152 :
No description.
Code »
function%153 :
No description.
Code »
function%154 :
No description.
Code »
function%155 :
No description.
Code »
function%156 :
No description.
Code »
function%157 :
No description.
Code »
function%158 :
No description.
Code »
function%159 :
No description.
Code »
function%160 :
No description.
Code »
function%161 :
No description.
Code »
function%162 :
No description.
Code »

Directory uri

File Reference