Options
All
  • Public
  • Public/Protected
  • All
Menu

Static utility methods for working with URLs.

Hierarchy

  • UrlUtilities

Index

Properties

Static protocolRegex

protocolRegex: RegExp

Methods

Static getUrlComponents

  • getUrlComponents(url: string): object
  • Gets the components of a url (eg. host, protocol, path, query, etc.).

    Parameters

    • url: string

    Returns object

    • hash: string
    • host: string
    • hostname: string
    • origin: string
    • path: string
    • port: string
    • protocol: string
    • query: string

Static resolveUrl

  • resolveUrl(baseAddress: string, relativeUrl: string, normalize?: boolean): string
  • Resolves a relative URL, returning a fully qualified URL.

    Parameters

    • baseAddress: string

      The base URL being resolved against.

    • relativeUrl: string

      The URL being resolved.

    • Optional normalize: boolean

      Optional. If set to true, will simplify the URL before returning.

    Returns string

Static simplify

  • simplify(url: string): string
  • Simplifies a URL by processing double dots (..) and single dots (.) in the URL. For example, /sites/MySite/viewers/ViewerA/VirtualDirectory/../../ is simplified to /sites/MySite/viewers/.

    Parameters

    • url: string

      The URL to simplify.

    Returns string

Static stripProtocol

  • stripProtocol(url: string): string
  • Strips the protocol from a url, useful for comparing urls when we want to ignore http/https

    Parameters

    • url: string

    Returns string