Class goog.Uri
code »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()
.
Constructor
Parameters |
---|
|
Classes
|
Instance Methods
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.
code »getDecodedQuery ( ) ⇒ string
string
Returns |
---|
|
code »getEncodedQuery ( ) ⇒ string
string
Returns |
---|
|
code »getFragment ( ) ⇒ string
string
Returns |
---|
|
code »getIgnoreCase ( ) ⇒ boolean
boolean
Returns |
---|
|
code »getParameterValue ( paramName ) ⇒ (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.
(string|undefined)
Parameters |
---|
|
Returns |
|
code »getParameterValues ( name ) ⇒ !Array
Returns the values for a given cgi parameter as a list of decoded
query parameter values.
!Array
Parameters |
---|
|
Returns |
|
Returns the query data.
Returns |
---|
|
code »getUserInfo ( ) ⇒ string
string
Returns |
---|
|
code »hasFragment ( ) ⇒ boolean
boolean
Returns |
---|
|
code »hasSameDomainAs ( uri2 ) ⇒ boolean
Returns true if this has the same domain as that of uri2.
boolean
Parameters |
---|
|
Returns |
|
code »hasUserInfo ( ) ⇒ boolean
boolean
Returns |
---|
|
code »isReadOnly ( ) ⇒ boolean
boolean
Returns |
---|
|
code »makeUnique ( ) ⇒ !goog.Uri
Adds a random parameter to the Uri.
!goog.Uri
Returns |
---|
|
code »removeParameter ( key ) ⇒ !goog.Uri
Removes the named query parameter.
!goog.Uri
Parameters |
---|
|
Returns |
|
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:
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 URI has a non-empty path, all ".." and "."
segments will be resolved, as described in RFC 3986.
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 URI has a non-empty path, all ".." and "." segments will be resolved, as described in RFC 3986.
Parameters |
---|
|
Returns |
|
code »setFragment ( newFragment, opt_decode ) ⇒ !goog.Uri
Sets the URI fragment.
!goog.Uri
code »setIgnoreCase ( 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.
!goog.Uri
Parameters |
---|
|
Returns |
|
code »setParameterValue ( key, value ) ⇒ !goog.Uri
Sets the value of the named query parameters, clearing previous values for
that key.
!goog.Uri
Parameters |
---|
|
Returns |
|
code »setParameterValues ( key, 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.
!goog.Uri
goog.Uri.parse('foo?a=b&c=d&e=f').setParameterValues('c', ['new'])
yields foo?a=b&e=f&c=new.Parameters |
---|
|
Returns |
|
code »setQueryData ( queryData, opt_decode ) ⇒ !goog.Uri
Sets the query data.
!goog.Uri
Parameters |
---|
|
Returns |
|
code »setReadOnly ( 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.
!goog.Uri
Parameters |
---|
|
Returns |
|
code »setUserInfo ( newUserInfo, opt_decode ) ⇒ !goog.Uri
Sets the userInfo.
!goog.Uri
Instance Properties
Whether or not to ignore case when comparing query params.
Whether or not this Uri should be treated as Read Only.
Object representing query data.
Static Functions
code »goog.Uri.create ( opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_query, opt_fragment, opt_ignoreCase ) ⇒ !goog.Uri
Creates a new goog.Uri object from unencoded parts.
!goog.Uri
Parameters |
---|
|
Returns |
|
code »goog.Uri.encodeChar_ ( ch ) ⇒ string
Converts a character in [\01-\177] to its unicode character equivalent.
string
Parameters |
---|
|
Returns |
|
code »goog.Uri.encodeSpecialChars_ ( unescapedPart, extra, opt_removeDoubleEncoding ) ⇒ ?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.
?string
code »goog.Uri.haveSameDomain ( uri1String, uri2String ) ⇒ boolean
Checks whether two URIs have the same domain.
boolean
code »goog.Uri.parse ( uri, 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.
!goog.Uri
Parameters |
---|
|
Returns |
|
code »goog.Uri.removeDotSegments ( path ) ⇒ string
Removes dot segments in given path component, as described in
RFC 3986, section 5.2.4.
string
Parameters |
---|
|
Returns |
|
code »goog.Uri.removeDoubleEncoding_ ( doubleEncodedString ) ⇒ string
Removes double percent-encoding from a string.
string
Parameters |
---|
|
Returns |
|
code »goog.Uri.resolve ( base, rel ) ⇒ !goog.Uri
Resolves a relative Uri against a base Uri, accepting both strings and
Uri objects.
!goog.Uri
Parameters |
---|
|
Returns |
|