parse-domain 0.1.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "parse-domain",
3
- "version": "0.1.1",
4
- "description": "Splits an url into sub-domain, domain and top-level-domain",
3
+ "version": "0.2.2",
4
+ "description": "Splits an url into sub-domain, domain and effective top-level-domain",
5
5
  "main": "./lib/parseDomain.js",
6
6
  "scripts": {
7
- "test": "node node_modules/mocha/bin/mocha -R spec"
7
+ "test": "mocha -R spec",
8
+ "download-tld": "curl https://publicsuffix.org/list/effective_tld_names.dat > lib/build/tld.txt",
9
+ "build-regex": "node lib/build/buildRegex.js",
10
+ "update-regex": "npm run download-tld && npm run build-regex && npm run test"
8
11
  },
9
12
  "keywords": [
10
13
  "domain",
@@ -17,29 +20,15 @@
17
20
  "country",
18
21
  "top-level"
19
22
  ],
20
- "dependencies": {},
21
- "devDependencies": {
22
- "mocha": "1.x",
23
- "chai": "1.x"
24
- },
25
23
  "repository": {
26
24
  "type": "git",
27
25
  "url": "https://github.com/peerigon/parse-domain.git"
28
26
  },
29
- "testling": {
30
- "harness" : "mocha",
31
- "files": "test/parseDomain.test.js",
32
- "browsers": [
33
- "ie/8..latest",
34
- "chrome/27..latest",
35
- "firefox/22..latest",
36
- "safari/latest",
37
- "opera/latest",
38
- "iphone/latest",
39
- "ipad/latest",
40
- "android-browser/latest"
41
- ]
42
- },
43
27
  "author": "peerigon <developers@peerigon.com>",
44
- "license": "Unlicense"
28
+ "license": "Unlicense",
29
+ "dependencies": {},
30
+ "devDependencies": {
31
+ "chai": "^3.5.0",
32
+ "mocha": "^3.1.0"
33
+ }
45
34
  }
@@ -1,107 +0,0 @@
1
- "use strict";
2
-
3
- var chai = require("chai"),
4
- expect = chai.expect,
5
- parseDomain = require("../lib/parseDomain.js");
6
-
7
- chai.config.includeStack = true;
8
-
9
- describe("parseDomain(url)", function () {
10
-
11
- it("should remove the protocol", function () {
12
- expect(parseDomain("http://example.com")).to.eql({
13
- subdomain: "",
14
- domain: "example",
15
- tld: "com"
16
- });
17
- expect(parseDomain("https://example.com")).to.eql({
18
- subdomain: "",
19
- domain: "example",
20
- tld: "com"
21
- });
22
- });
23
-
24
- it("should remove sub-domains", function () {
25
- expect(parseDomain("www.example.com")).to.eql({
26
- subdomain: "www",
27
- domain: "example",
28
- tld: "com"
29
- });
30
- expect(parseDomain("www.some.other.subdomain.example.com")).to.eql({
31
- subdomain: "www.some.other.subdomain",
32
- domain: "example",
33
- tld: "com"
34
- });
35
- });
36
-
37
- it("should remove the path", function () {
38
- expect(parseDomain("example.com/some/path?and&query")).to.eql({
39
- subdomain: "",
40
- domain: "example",
41
- tld: "com"
42
- });
43
- expect(parseDomain("example.com/")).to.eql({
44
- subdomain: "",
45
- domain: "example",
46
- tld: "com"
47
- });
48
- });
49
-
50
- it("should remove the port", function () {
51
- expect(parseDomain("example.com:8080")).to.eql({
52
- subdomain: "",
53
- domain: "example",
54
- tld: "com"
55
- });
56
- });
57
-
58
- it("should remove the authentication", function () {
59
- expect(parseDomain("user:password@example.com")).to.eql({
60
- subdomain: "",
61
- domain: "example",
62
- tld: "com"
63
- });
64
- });
65
-
66
- it("should also work with three-level domains like .co.uk", function () {
67
- expect(parseDomain("www.example.co.uk")).to.eql({
68
- subdomain: "www",
69
- domain: "example",
70
- tld: "co.uk"
71
- });
72
- });
73
-
74
- it("should work when all url parts are present", function () {
75
- expect(parseDomain("https://user@www.some.other.subdomain.example.co.uk:8080/some/path?and&query#hash")).to.eql({
76
- subdomain: "www.some.other.subdomain",
77
- domain: "example",
78
- tld: "co.uk"
79
- });
80
- });
81
-
82
- it("should also work with the minimum", function () {
83
- expect(parseDomain("example.com")).to.eql({
84
- subdomain: "",
85
- domain: "example",
86
- tld: "com"
87
- });
88
- });
89
-
90
- it("should return null if the given url contains an unsupported top-level domain", function () {
91
- expect(parseDomain("example.kk")).to.equal(null);
92
- });
93
-
94
- it("should return null if the given value is not a string", function () {
95
- expect(parseDomain(undefined)).to.equal(null);
96
- expect(parseDomain({})).to.equal(null);
97
- });
98
-
99
- it("should work with domains that could match multiple tlds", function() {
100
- expect(parseDomain("http://hello.de.ibm.com")).to.eql({
101
- subdomain: "hello.de",
102
- domain: "ibm",
103
- tld: "com"
104
- });
105
- });
106
-
107
- });