Retrieves the parent pathname of a given URL by removing the last segment of the pathname.
parentPathname("https://www.example.com/page/subpage")// => { ok: true, value: 'page' } Copy
parentPathname("https://www.example.com/page/subpage")// => { ok: true, value: 'page' }
Handle an invalid input:
parentPathname("page/subpage")// => { ok: false, error: Error('[urls.parentPathname] Expected a valid URL') } Copy
parentPathname("page/subpage")// => { ok: false, error: Error('[urls.parentPathname] Expected a valid URL') }
The URL for which the parent pathname needs to be retrieved.
A Result object with either a string representing the parent pathname 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
Retrieves the parent pathname of a given URL by removing the last segment of the pathname.
Example
Example
Handle an invalid input: