Provides a utility function to parse / construct fully qualified URL instances from a URL string.

Constructors

Methods

Constructors

Methods

  • Parses a URL string converting it to a fully qualified URL. If URL is an existing URL instance it is returned immediately. Optionally you may construct a fully qualified URL from a relative base origin / path or with a route prefix added to the current location origin.

    Parameters

    • options: {
          base?: string;
          routePrefix?: string;
          url: string | URL;
      }

      Options.

      • Optionalbase?: string

        Optional fully qualified base path for relative URL construction.

      • OptionalroutePrefix?: string

        Optional route prefix to add to location origin for absolute URL strings when base is not defined.

      • url: string | URL

        URL string to convert to a URL.

    Returns URL

    Parsed URL or null if url is not parsed.