Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/kimromi/split-domain.js
- Owner: kimromi
- License: mit
- Created: 2018-06-27T15:27:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-13T06:34:57.000Z (over 6 years ago)
- Last Synced: 2024-09-19T05:44:31.478Z (3 months ago)
- Topics: domain, javascript, splitter, typescript
- Language: TypeScript
- Homepage:
- Size: 22.5 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
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 RequestAuthor
------[kimromi](https://github.com/kimromi)