URI

Implementation of URI parsing and base URI resolving algorithm in RFC 3986.

new YS.URI(uri)

Constructs a URI object.
Name Type Description
uri string | URI A string or URI object to create the object from.

Methods

equals()

Simple String Comparison of two URIs. See RFC 3986 section 6.2.1. To perform more thorough comparison, you can normalise the URI objects.

getAuthority()

Returns the authority part of the URI. In "http://example.com:80/a/b?x#y" this is "example.com:80".

getFragment()

Returns the fragment part of the URI. In "http://example.com:80/a/b?x#y" this is "y".

getPath()

Returns the path part of the URI. In "http://example.com:80/a/b?x#y" this is "/a/b". In "mailto:mike@example.com" this is "mike@example.com".

getQuery()

Returns the query part of the URI. In "http://example.com:80/a/b?x#y" this is "x".

getScheme()

Returns the scheme part of the URI. In "http://example.com:80/a/b?x#y" this is "http".

isAbsolute()

Tests whether the URI is an absolute URI. See RFC 3986 section 4.3.

isSameDocumentAs()

Tests whether the URI is a same-document reference. See RFC 3986 section 4.4. To perform more thorough comparison, you can normalise the URI objects.

normalize()

Normalizes the URI using syntax-based normalization. This includes case normalization, percent-encoding normalization and path segment normalization. XXX: Percent-encoding normalization does not escape characters that need to be escaped. (Although that would not be a valid URI in the first place. See validate().) See RFC 3986 section 6.2.2.

resolve()

Resolve a relative URI (this) against a base URI. The base URI must be an absolute URI. See RFC 3986 section 5.2

toString()

Serialises the URI to a string.