Home

Class goog.Uri

This class contains setters and getters for the parts of the URI. The getXyz/setXyz methods return the decoded part -- sogoog.Uri.parse('/foo%20bar').getPath() will return the decoded path, /foo bar. The constructor accepts an optional unparsed, raw URI string. The parser is relaxed, so special characters that aren't escaped but don't cause ambiguities will not cause parse failures. All setters return this and so may be chained, a la goog.Uri.parse('/foo').setFragment('part').toString().

Instance Method Summary
clone() ⇒ !goog.Uri

Clones the URI instance.

enforceReadOnly()

Checks if this Uri has been marked as read only, and if so, throws an error. This should be called whenever any modifying function is called.

getDecodedQuery() ⇒ string
getDomain() ⇒ string
getEncodedQuery() ⇒ string
getFragment() ⇒ string
getIgnoreCase() ⇒ boolean
getParameterValue(string paramName) ⇒ <Any Type>

Returns the first value for a given cgi parameter or undefined if the given parameter name does not appear in the query string.

getParameterValues(string name) ⇒ ?Array

Returns the values for a given cgi parameter as a list of decoded query parameter values.

getPath() ⇒ string
getPort() ⇒ ?number
getQuery() ⇒ string
getQueryData() ⇒ ?goog.Uri.QueryData

Returns the query data.

getScheme() ⇒ string
getUserInfo() ⇒ string
hasDomain() ⇒ boolean
hasFragment() ⇒ boolean
hasPath() ⇒ boolean
hasPort() ⇒ boolean
hasQuery() ⇒ boolean
hasSameDomainAs(?goog.Uri uri2) ⇒ boolean

Returns true if this has the same domain as that of uri2.

hasScheme() ⇒ boolean
hasUserInfo() ⇒ boolean
isReadOnly() ⇒ boolean
makeUnique() ⇒ !goog.Uri

Adds a random parameter to the Uri.

removeParameter(string key) ⇒ !goog.Uri

Removes the named query parameter.

resolve(?goog.Uri relativeUri) ⇒ !goog.Uri

Resolves a relative url string to a this base uri. There are several kinds of relative urls:
1. foo - replaces the last part of the path, the whole query and fragment
2. /foo - replaces the the path, the query and fragment
3. //foo - replaces everything from the domain on. foo is a domain name
4. ?foo - replace the query and fragment
5. #foo - replace the fragment only Additionally, if relative url has a non-empty path, all ".." and "." segments will be resolved, as described in RFC 3986.

setDomain(string newDomain, boolean= opt_decode) ⇒ !goog.Uri

Sets the domain.

setFragment(string newFragment, boolean= opt_decode) ⇒ !goog.Uri

Sets the URI fragment.

setIgnoreCase(boolean ignoreCase) ⇒ !goog.Uri

Sets whether to ignore case. NOTE: If there are already key/value pairs in the QueryData, and ignoreCase_ is set to false, the keys will all be lower-cased.

setParameterValue(string key, <Any Type> value) ⇒ !goog.Uri

Sets the value of the named query parameters, clearing previous values for that key.

setParameterValues(string key, <Any Type> values) ⇒ !goog.Uri

Sets the values of the named query parameters, clearing previous values for that key. Not new values will currently be moved to the end of the query string. So, goog.Uri.parse('foo?a=b&c=d&e=f').setParameterValues('c', ['new']) yields foo?a=b&e=f&c=new.

setPath(string newPath, boolean= opt_decode) ⇒ !goog.Uri

Sets the path.

setPort(<Any Type> newPort) ⇒ !goog.Uri

Sets the port number.

setQuery(string newQuery, boolean= opt_decode) ⇒ !goog.Uri

Sets the URI query.

setQueryData((goog.Uri.QueryData|null|string|undefined) queryData, boolean= opt_decode) ⇒ !goog.Uri

Sets the query data.

setReadOnly(boolean isReadOnly) ⇒ !goog.Uri

Sets whether Uri is read only. If this goog.Uri is read-only, enforceReadOnly_ will be called at the start of any function that may modify this Uri.

setScheme(string newScheme, boolean= opt_decode) ⇒ !goog.Uri

Sets the scheme/protocol.

setUserInfo(string newUserInfo, boolean= opt_decode) ⇒ !goog.Uri

Sets the userInfo.

toString() ⇒ string
Static Method Summary
create(?string= opt_scheme, ?string= opt_userInfo, ?string= opt_domain, ?number= opt_port, ?string= opt_path, (goog.Uri.QueryData|null|string=) opt_query, ?string= opt_fragment, boolean= opt_ignoreCase) ⇒ !goog.Uri

Creates a new goog.Uri object from unencoded parts.

decodeOrEmpty_((string|undefined) val) ⇒ string

Decodes a value or returns the empty string if it isn't defined or empty.

encodeChar_(string ch) ⇒ string

Converts a character in [\01-\177] to its unicode character equivalent.

encodeSpecialChars_(<Any Type> unescapedPart, ?RegExp extra) ⇒ ?string

If unescapedPart is non null, then escapes any characters in it that aren't valid characters in a url and also escapes any special characters that appear in extra.

encodeString_(<Any Type> unescapedPart) ⇒ ?string

URI encode a string, or return null if it's not a string.

haveSameDomain(string uri1String, string uri2String) ⇒ boolean

Checks whether two URIs have the same domain.

parse(<Any Type> uri, boolean= opt_ignoreCase) ⇒ !goog.Uri

Creates a uri from the string form. Basically an alias of new goog.Uri(). If a Uri object is passed to parse then it will return a clone of the object.

removeDotSegments(string path) ⇒ string

Removes dot segments in given path component, as described in RFC 3986, section 5.2.4.

resolve(<Any Type> base, <Any Type> rel) ⇒ !goog.Uri

Resolves a relative Uri against a base Uri, accepting both strings and Uri objects.