sindresorhus / normalize-url

Normalize a URL
MIT License
837 stars 123 forks source link

Is there an (efficient) way to extract the domain only? #182

Closed jahamed closed 1 year ago

jahamed commented 1 year ago

Using 'stripProtocol' to remove http/https but I would like to change audlindin.is/##.owl-stage-outer to audlindin.is

Am I missing an option or is there an efficient way to do this?

Basically want to extract the domain name only if possible :)

sindresorhus commented 1 year ago

You can use stripTextFragment: true too. But it's simpler to just do new URL(url).hostname.