getDomain
Extract the hostname from a URL string, returning the domain portion so you can compare, filter, or display the origin of a link.
Usage
getDomain extracts the hostname portion from a URL.
import { getDomain } from '@movk/core'
getDomain('https://sub.example.com/path') // 'sub.example.com'
getDomain('https://example.com:8080') // 'example.com'
API
getDomain(url)
Extract the domain from a URL.
Parameters
url
string required
The URL string.
Returns
returns
string
The domain name, or an empty string if parsing fails.
Changelog
No recent changes