Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kimromi/split-domain.js

✂️ simple domain name splitter for Node.js
https://github.com/kimromi/split-domain.js

domain javascript splitter typescript

Last synced: about 1 month ago
JSON representation

✂️ simple domain name splitter for Node.js

Awesome Lists containing this project

README

        

split-domain.js
===============

Simple domain name splitter.




Installation
------------

```sh
$ npm install split-domain --save
```

Usage
-----

### Node.js

```javascript
import splitDomain from 'split-domain'

const domain = splitDomain('example.com')
domain.subDomain // => ''
domain.sld // => 'example'
domain.tld // => 'com'

const domain = splitDomain('sub.example.com')
domain.subDomain // => 'sub'
domain.sld // => 'example'
domain.tld // => 'com'

const domain = splitDomain('example.co.jp')
domain.subDomain // => ''
domain.sld // => 'example'
domain.tld // => 'co.jp'

const domain = splitDomain('sub.example.co.jp')
domain.subDomain // => 'sub'
domain.sld // => 'example'
domain.tld // => 'co.jp'
```

TypeSctipt

```typescript
import splitDomain, { SplitDomain } from 'split-domain'

const domain: SplitDomain = splitDomain('example.com')
domain.subDomain // => ''
domain.sld // => 'example'
domain.tld // => 'com'

const domain: SplitDomain = splitDomain('sub.example.com')
domain.subDomain // => 'sub'
domain.sld // => 'example'
domain.tld // => 'com'

const domain: SplitDomain = splitDomain('example.co.jp')
domain.subDomain // => ''
domain.sld // => 'example'
domain.tld // => 'co.jp'

const domain: SplitDomain = splitDomain('sub.example.co.jp')
domain.subDomain // => 'sub'
domain.sld // => 'example'
domain.tld // => 'co.jp'
```

Contribution
------------

1. Fork (https://github.com/kimromi/domainSplitter.js/fork)
1. Create a feature branch
1. Commit your changes
1. Rebase your local changes against the master branch
1. Run test suite with the `npm ci` command and confirm that it passes
1. Create a new Pull Request

Author
------

[kimromi](https://github.com/kimromi)