Extracts the hostname from a URL string.
getHostname('https://sub.example.com/path?query=123'); // 'sub.example.com'getHostname('https://sub.example.com:8080/path?query=123'); // 'sub.example.com'getHostname('invalid-url'); // undefined Copy
getHostname('https://sub.example.com/path?query=123'); // 'sub.example.com'getHostname('https://sub.example.com:8080/path?query=123'); // 'sub.example.com'getHostname('invalid-url'); // undefined
Extracts the hostname from a URL string.