IRIs are unicode URIs, URIs by definition being 7-bit characters.
From RFC 3986:
foo://example.com:8042/over/there?name=ferret#nose \_/ \______________/\_________/ \_________/ \__/ | | | | | scheme authority path query fragment | _____________________|__ / \ / \ urn:example:animal:ferret:nose
The authority exists in a URI/IRI and is marked by a leading
//. It can be broken down into a number of other components:
root:hunter2@[::1]:8080 \__________/ \___/ \__/ | | | userinfo host port
The constructor takes a single argument, a URI or IRI string:
var iri = require('iri'); var path = new iri.IRI(str).resolveReference('/');
Returns UTF-16 IRI
Returns the IRI without the fragment component. Useful for dereferencing URLs on a network.
new IRI().defrag() === 'http://example.com/resource'
IRIs with a fragment are not absolute.
Resolves the IRI against itself, having the effect of stripping the fragment and checking that the supplied IRI is valid (absolute).
Returns the authority component of the IRI, such as "user:firstname.lastname@example.org:8080"
Returns the fragment component of the IRI.
Returns the hier-part of the IRI, the hierarchial component: Everything between the scheme and query, including leading
// for the host, if it exists.
Returns the host component of the URI, either a domain name or string-formatted IP address. Excludes port number and username/password.
Returns the path component of the hier-part. Does not include the authority/host, query, or fragment.
Returns the port component of the authority as a string, or null if there is no port.
Returns the query component of the IRI including leading "?", or
null if there is no query component.
Resolve the provided URI/IRI reference against this IRI.
Returns the scheme of the IRI, e.g. "https", "file", or "urn".
Returns the username/password component of the IRI.
Returns a URI formatted string with only 7-bit characters.
Returns a new IRI object with URI-encoded UTF-8 characters decoded.
Returns an iri.IRI object with UTF-8 escaped characterd decoded.
Returns an IRI string decoded from the given URI.
Tests are available as a Vows test suite. Run
vows in the package directory to execute.