ImmutableURIinterface

{
	readonly hash: URIHash | ``;
	readonly host: string;
	readonly hostname: string;
	readonly href: URIString;
	readonly origin: URIString | `null`;
	readonly password: string;
	readonly pathname: string;
	readonly port: string;
	readonly protocol: URIScheme;
	readonly search: URISearch | ``;
	readonly username: string;
}
PropertyType
.hashURIHash
``
Hash component of the URI, including the leading # (empty string if absent). required readonly
.hoststring
Host component of the URI (hostname and port), or empty string for non-hierarchical URIs. required readonly
.hostnamestring
Hostname component of the URI, or empty string for non-hierarchical URIs. required readonly
.hrefURIString
Full URI string. required readonly
.originURIString
`null`
Origin of the URI, or the string "null" for origins that cannot be serialised. required readonly
.passwordstring
Password component of the URI (empty string if absent). required readonly
.pathnamestring
Pathname component of the URI. required readonly
.portstring
Port component of the URI (empty string if absent). required readonly
.protocolURIScheme
Protocol scheme of the URI, including the trailing : required readonly
.searchURISearch
``
Search component of the URI, including the leading ? (empty string if absent). required readonly
.usernamestring
Username component of the URI (empty string if absent). required readonly

Object that describes a valid URI, e.g. urn:isbn:0451450523 or http://example.com/path/to/resource

  • Improves the builtin Javascript URL class to more accurately type its properties.

URI and URL differences:

  • According to RFC 3986, URLs are a subset of URIs that have a hierarchical path component, e.g. http://example.com/path.
  • The // at the start of a URL indicates that it has a hierarchical path component, so this makes it a URL.
  • The absence of // indicates a non-hierarchical URI.
  • URLs can be considered as "hierarchical URIs".
  • All URLs are also URIs, but not all URIs are URLs.