Class URL

The URL interface is used to parse, construct, normalize, and encode URLs. It works by providing properties which allow you to easily read and modify the components of a URL.

You normally create a new URL object by specifying the URL as a string when calling its constructor, or by providing a relative URL and a base URL. You can then easily read the parsed components of the URL or make changes to the URL.

Hierarchy

  • URL

Implements

Constructors

  • Constructs a new URL object by parsing the specified URL.

    Parameters

    • url: string | URL

      The input URL to be parsed.

    • Optional base: string | URL

      The base URL to use in case the input URL is a relative URL.

    Returns URL

Properties

hash: string
host: string
hostname: string
href: string
origin: string
password: string
pathname: string
port: string
protocol: string
search: string
username: string

Accessors

  • get searchParams(): URLSearchParams
  • Returns URLSearchParams

Methods

  • Returns a string containing the full URL. It is a synonym for the href property.

    Returns string

  • Returns a string containing the full URL. It is a synonym for the href property, though it can't be used to modify the value.

    Returns string

  • Returns a boolean indicating whether or not an absolute URL, or a relative URL combined with a base URL, are parsable and valid.

    Parameters

    • url: string | URL

      The input URL to be parsed.

    • Optional base: string | URL

      The base URL to use in case the input URL is a relative URL.

    Returns void

  • Returns a string containing a URL which represents the provided Blob object.

    Parameters

    • obj: Blob

      The object for which an object URL is to be created.

    Returns string

  • Revokes an object URL previously created using URL.createObjectURL().

    Parameters

    • url: string

      A string representing a URL that was created by calling URL.createObjectURL().

    Returns void

Generated using TypeDoc