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.
parentUrl("https://example.com/blog/posts/welcome/")// => { ok: true, value: 'https://example.com/blog/posts' } Copy
parentUrl("https://example.com/blog/posts/welcome/")// => { ok: true, value: 'https://example.com/blog/posts' }
Handle an invalid input:
parentUrl("/welcome")// => { ok: false, error: Error('[urls.parentUrl] Expected a valid URL') } Copy
parentUrl("/welcome")// => { ok: false, error: Error('[urls.parentUrl] Expected a valid URL') }
The URL for which the parent URL needs to be retrieved.
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.
Result
Error
Generated using TypeDoc v0.24.7
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
Example
Handle an invalid input: