1.0.0 • Published 7 years ago

url-slicer v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Build Status

url-slicer.js

Slice URLs into logical parts - domain, tld or subdomains for node.js

Installation

Install by running npm install url-slicer

Usage

var urlSlicer = require('url-slicer');

urlSlicer.slice('http://dir.com', function(err, sliced) {
    console.log(sliced);
});

Output:

{ domain: 'dir',
  tld: 'com',
  query: undefined,
  subdomains: [] }

Url Slicer is using the public suffix list which can be found here https://publicsuffix.org/list/.

More examples

//http://police.uk
not valid
//http://www.police.uk
{ domain: 'www',
  tld: 'police.uk',
  query: undefined,
  subdomains: [] }
//my.agriculture.museum
{ domain: 'my',
  tld: 'agriculture.museum',
  query: undefined,
  subdomains: [] }

API

urlSlicer.init()

Returns promise when publix suffix list is downloaded and loaded.

urlSlicer.slice(url)

Returns object with sliced url data:

{ domain: 'google',
  tld: 'com',
  query: undefined,
  subdomains: [] }

SliceException is thrown on slice error.

1.0.0

7 years ago

0.3.4

8 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

10 years ago

0.1.0

10 years ago