search

goog.url

Module ID

Class for parsing strings into URLs using browser native resolution.

Use resolveUrl to resolve a url string with an optional base url string to URL. Will throw an error if the resulting URL would not be valid. This can be used in place of the [URL Web API][1] while providing support in IE and working around various inconsistencies in Edge.

Use resolveRelativeUrl to resolve any relative URL into an absolute URL for the current location.

Use createUrl to easily construct a new URL from an existing URL.

This package attempts to follow the [WHATWG URL standard][2] where possible, deviating only when there are significant advantages to doing so such as splitting out searchParams from a property to a function call to allow the compiler to remove the relevant polyfill code if unused, or removing functionality that can cause confusion, unexpected results, or unnecessary code size increases to the package. This package also adds checks that are missing in some browsers (e.g. throwing errors when a potential URL doesn't have a protocol or hostname), and generally tries to ensure consistency among browsers while still accurately reporting how a browser will interpret a given URL.

Unlike goog.URI, this package is NOT intended to be used with URLs that are "special", and is only guaranteed to return useful results for the schemes listed in the spec (http(s), ws(s), ftp, file, blob). Various browsers (Chrome included) do not correctly parse special URLs and the results will be inaccurate in those cases. If you need to parse URLs using these protocols, prefer to use goog.Uri (or goog.uri.utils) instead. [1]: https://developer.mozilla.org/en-US/docs/Web/API/URL [2]: https://url.spec.whatwg.org/

Exported Functions

Exported Interfaces