get-apex-domain-name

Robustly parses the root / apex domain name of a URL without the TLD.

Usage no npm install needed!

<script type="module">
  import getApexDomainName from 'https://cdn.skypack.dev/get-apex-domain-name';
</script>

README

get-apex-domain-name

Robustly parses the root / apex domain name of a URL without the TLD.

NPM Build Status JavaScript Style Guide

Install

npm install --save get-apex-domain-name

Usage

const getApexDomainName = require('get-apex-domain-name')

getApexDomainName('https://example.com') // 'example'
getApexDomainName('example.com') // 'example'
getApexDomainName('example.co.uk') // 'example'
getApexDomainName('https://example.dev/sub/path?foo=bar&nala=cat') // 'example'
getApexDomainName('') // null

License

MIT © Travis Fischer

Support my OSS work by following me on twitter twitter