goog.Uri
Provided By |
---|
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
.
Reserved characters (see RFC 3986 section 2.2) can be present in
their percent-encoded form in scheme, domain, and path URI components and
will not be auto-decoded. For example:
goog.Uri.parse('rel%61tive/path%2fto/resource').getPath()
will
return relative/path%2fto/resource
.
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()
.
new Uri( opt_uri, opt_ignoreCase )
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Throws |
|
Instance Methods
this.clone() → goog.Uri
goog.Uri
this.enforceReadOnly() → void
void
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.
this.getDecodedQuery() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getDomain() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getEncodedQuery() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getFragment() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getIgnoreCase() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getParameterValue( paramName ) → (string|undefined)
(string|undefined)
Returns the first value for a given cgi parameter or undefined if the given parameter name does not appear in the query string.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.getParameterValues( name ) → Array<?>
Array<?>
this.getPath() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getPort() → (number|null)
(number|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getQuery() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getQueryData() → goog.Uri.QueryData
goog.Uri.QueryData
this.getScheme() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getUserInfo() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.hasDomain() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.hasFragment() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.hasPath() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.hasPort() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.hasQuery() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.hasSameDomainAs( uri2 ) → boolean
boolean
this.hasScheme() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.hasUserInfo() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isReadOnly() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.makeUnique() → goog.Uri
goog.Uri
Adds a random parameter to the Uri.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.removeParameter( key ) → goog.Uri
goog.Uri
this.resolve( relativeUri ) → goog.Uri
goog.Uri
Resolves the given relative URI (a goog.Uri object), using the URI represented by this instance as the base URI.
There are several kinds of relative URIs:
- foo - replaces the last part of the path, the whole query and fragment
- /foo - replaces the path, the query and fragment
- //foo - replaces everything from the domain on. foo is a domain name
- ?foo - replace the query and fragment
- #foo - replace the fragment only
Additionally, if relative URI has a non-empty path, all ".." and "." segments will be resolved, as described in RFC 3986.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.setDomain( newDomain, opt_decode ) → goog.Uri
goog.Uri
this.setFragment( newFragment, opt_decode ) → goog.Uri
goog.Uri
this.setIgnoreCase( ignoreCase ) → goog.Uri
goog.Uri
this.setParameterValue( key, value ) → goog.Uri
goog.Uri
this.setParameterValues( key, values ) → goog.Uri
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.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.setPath( newPath, opt_decode ) → goog.Uri
goog.Uri
this.setPort( newPort ) → goog.Uri
goog.Uri
Sets the port number.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.setQuery( newQuery, opt_decode ) → goog.Uri
goog.Uri
this.setQueryData( queryData, opt_decode ) → goog.Uri
goog.Uri
Sets the query data.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.setReadOnly( isReadOnly ) → goog.Uri
goog.Uri
this.setScheme( newScheme, opt_decode ) → goog.Uri
goog.Uri
this.setUserInfo( newUserInfo, opt_decode ) → goog.Uri
goog.Uri
this.toString() → string
string
Parameters | None. | ||
---|---|---|---|
Returns |
|
Static Functions
Uri.create( opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_query, opt_fragment, opt_ignoreCase ) → goog.Uri
goog.Uri
Creates a new goog.Uri object from unencoded parts.
Parameters |
| ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
Uri.haveSameDomain( uri1String, uri2String ) → boolean
boolean
Uri.parse( uri, opt_ignoreCase ) → goog.Uri
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.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
Throws |
|
Uri.removeDotSegments( path ) → string
string
Uri.resolve( base, rel ) → goog.Uri
goog.Uri
Resolves a relative Uri against a base Uri, accepting both strings and Uri objects.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Static Properties
Uri.RANDOM_PARAM → string
string
Parameter name added to stop caching.