Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2nd level domain as custom TLD? #8

Closed
akost opened this issue Sep 16, 2016 · 1 comment
Closed

2nd level domain as custom TLD? #8

akost opened this issue Sep 16, 2016 · 1 comment

Comments

@akost
Copy link
Contributor

akost commented Sep 16, 2016

Is it possible to pass a second level domain as a custom TLD? Looks like it does not work.

e.g. I have foo.example.com and I want to get 'foo' as domain and 'example.com' as TLD.

Sample code:

var parseDomain = require('parse-domain');
var url = "foo.example.com";
var parsed_domain = parseDomain(url, { customTlds:[ "example.com"] });

console.log(parsed_domain);

Output

{ tld: 'com', domain: 'example', subdomain: 'foo' }

Expected Output

{ tld: 'example.com', domain: 'foo', subdomain: '' }

Thank you!

@jhnns
Copy link
Member

jhnns commented Oct 14, 2016

The customTlds option also accepts regular expressions. You should be able to create a pattern for that case :)

@jhnns jhnns closed this as completed Oct 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants