Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parse-domain

Package Overview
Dependencies
Maintainers
6
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-domain - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

20

CHANGELOG.md

@@ -5,2 +5,22 @@ # Change Log

<a name="2.0.0"></a>
# [2.0.0](https://github.com/peerigon/parse-domain/compare/v1.2.0...v2.0.0) (2017-12-03)
### Code Refactoring
* Update code to node 4 ([4d87f43](https://github.com/peerigon/parse-domain/commit/4d87f43))
### Features
* Update list of TLDs ([df15b19](https://github.com/peerigon/parse-domain/commit/df15b19))
### BREAKING CHANGES
* node 4 or newer is required
<a name="1.2.0"></a>

@@ -7,0 +27,0 @@ # [1.2.0](https://github.com/peerigon/parse-domain/compare/v1.1.0...v1.2.0) (2017-12-03)

34

lib/build/buildRegex.js
"use strict";
var fs = require("fs");
var path = require("path");
const fs = require("fs");
const path = require("path");
var txtPath = path.resolve(__dirname, "./tld.txt");
var regexPath = path.resolve(__dirname, "../tld.js");
var txtContent;
var icannContent;
var privateContent;
var icannTld;
var privateTld;
var src;
var regex;
const txtPath = path.resolve(__dirname, "./tld.txt");
const regexPath = path.resolve(__dirname, "../tld.js");
console.log("Reading " + txtPath + " ...");
txtContent = fs.readFileSync(txtPath, "utf8");
icannContent = txtContent.slice(
const txtContent = fs.readFileSync(txtPath, "utf8");
const icannContent = txtContent.slice(
txtContent.indexOf("// ===BEGIN ICANN DOMAINS==="),
txtContent.indexOf("// ===END ICANN DOMAINS===")
);
privateContent = txtContent.slice(
const privateContent = txtContent.slice(
txtContent.indexOf("// ===BEGIN PRIVATE DOMAINS==="),
txtContent.indexOf("// ===END PRIVATE DOMAINS===")
);
icannTld = icannContent.replace(/(\/\/.+)\r?\n/gi, "")
const icannTld = icannContent.replace(/(\/\/.+)\r?\n/gi, "")
.replace(/[\r?\n]+/g, "|")

@@ -34,3 +25,3 @@ .replace(/\./g, "\\.")

.slice(1, -1);
privateTld = privateContent.replace(/(\/\/.+)\r?\n/gi, "")
const privateTld = privateContent.replace(/(\/\/.+)\r?\n/gi, "")
.replace(/[\r?\n]+/g, "|")

@@ -40,4 +31,5 @@ .replace(/\./g, "\\.")

.slice(1, -1);
src = [
const src = [
'"use strict";',
"",
"exports = module.exports = /\\.(" + icannTld + "|$" + privateTld + ")$/;",

@@ -54,3 +46,3 @@ "exports.icann = /\\.(" + icannTld + ")$/;",

regex = require(regexPath); // eslint-disable-line import/no-dynamic-require
const regex = require(regexPath); // eslint-disable-line import/no-dynamic-require

@@ -57,0 +49,0 @@ if (regex instanceof RegExp === false) {

@@ -12,3 +12,3 @@ "use strict";

function normalizeOptions(options) {
var normalized = !options || typeof options !== "object" ? Object.create(null) : options;
const normalized = !options || typeof options !== "object" ? Object.create(null) : options;

@@ -15,0 +15,0 @@ if ("privateTlds" in normalized === false) {

"use strict";
var knownTlds = require("./tld.js");
var normalize = require("./normalize.js");
const knownTlds = require("./tld.js");
const normalize = require("./normalize.js");
var urlParts = /^(https?:\/\/)?([^/]*@)?(.+?)(:\d{2,5})?([/?].*)?$/; // 1 = protocol, 2 = auth, 3 = domain, 4 = port, 5 = path
var dot = /\./g;
const urlParts = /^(https?:\/\/)?([^/]*@)?(.+?)(:\d{2,5})?([/?].*)?$/; // 1 = protocol, 2 = auth, 3 = domain, 4 = port, 5 = path
const dot = /\./g;
function matchTld(domain, options) {
var tld = null;
let tld = null;

@@ -45,8 +45,6 @@ // for potentially unrecognized tlds, try matching against custom tlds

function parseDomain(url, options) {
var normalizedUrl = normalize.url(url);
var tld = null;
var normalizedOptions;
var urlSplit;
var domain;
var subdomain;
const normalizedUrl = normalize.url(url);
let tld = null;
let urlSplit;
let domain;

@@ -57,3 +55,3 @@ if (normalizedUrl === null) {

normalizedOptions = normalize.options(options);
const normalizedOptions = normalize.options(options);

@@ -77,8 +75,8 @@ // urlSplit can't be null because urlParts will always match at the third capture

domain = urlSplit.pop();
subdomain = urlSplit.join(".");
const subdomain = urlSplit.join(".");
return {
tld: tld,
domain: domain,
subdomain: subdomain,
tld,
domain,
subdomain,
};

@@ -85,0 +83,0 @@ }

{
"name": "parse-domain",
"version": "1.2.0",
"version": "2.0.0",
"description": "Splits an url into sub-domain, domain and effective top-level-domain",
"main": "./lib/parseDomain.js",
"scripts": {
"test": "mocha -R spec",
"test": "nyc mocha -R spec",
"posttest": "eslint lib test",
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha",
"download-tld": "curl https://publicsuffix.org/list/public_suffix_list.dat > lib/build/tld.txt",

@@ -37,5 +36,11 @@ "build-regex": "node lib/build/buildRegex.js",

"eslint-config-peerigon": "^12.0.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsdoc": "^3.2.0",
"mocha": "^4.0.1",
"nyc": "^11.3.0",
"standard-version": "^4.2.0"
}
},
"files": [
"lib"
]
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc