Function parentUrl

  • Returns a Result object with either a URL instance representing the parent URL if the given URL is valid, or an Error if the given URL is not valid.

    Example

    parentUrl("https://example.com/blog/posts/welcome/")
    // => { ok: true, value: 'https://example.com/blog/posts' }

    Example

    Handle an invalid input:

    parentUrl("/welcome")
    // => { ok: false, error: Error('[urls.parentUrl] Expected a valid URL') }

    Parameters

    • url: string

      The URL for which the parent URL needs to be retrieved.

    Returns Result<URL, Error>

    A Result object containing a URL instance representing the parent URL if the given URL is valid, or an Error object if the given URL is not valid.

Generated using TypeDoc v0.24.7