Socket
Socket
Sign inDemoInstall

parse-domain

Package Overview
Dependencies
0
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

26

lib/build/buildRegex.js

@@ -6,14 +6,30 @@ "use strict";

var tld,
var txtPath = path.resolve(__dirname, "./tld.txt"),
regexPath = path.resolve(__dirname, "../tld.js"),
tld,
src;
tld = fs.readFileSync(__dirname + "/tld.txt", "utf8")
console.log("Reading " + txtPath + " ...");
tld = fs.readFileSync(txtPath, "utf8")
.replace(/(\/\/.+)\r?\n/gi, "")
.replace(/[\r?\n]+/g, "|")
.replace(/\./g, "\\.")
.replace(/\*/g, "[^\\.]*")
.replace(/\*/g, "[^.]+")
.slice(1, -1);
src = "module.exports = /.(" + tld + ")$/;";
src = "module.exports = /\\.(" + tld + ")$/;";
fs.writeFileSync(path.resolve(__dirname, "../tld.js"), src, "utf8");
console.log("Writing module at " + regexPath + " ...");
fs.writeFileSync(regexPath, src, "utf8");
console.log("Checking if it's valid JavaScript ...");
var regex = require(regexPath);
if (regex instanceof RegExp === false) {
throw new Error("Generated regex is not instanceof RegExp. Instead saw " + regex);
}
console.log("Regex is ok, exiting now");

4

lib/parseDomain.js

@@ -40,6 +40,4 @@ "use strict";

// urlSplit can't be null because urlParts will always match at the third capture
urlSplit = url.toLowerCase().match(urlParts);
if (urlSplit === null) {
return null;
}
domain = urlSplit[3]; // domain will now be something like sub.domain.example.com

@@ -46,0 +44,0 @@

{
"name": "parse-domain",
"version": "0.1.1",
"version": "0.1.2",
"description": "Splits an url into sub-domain, domain and top-level-domain",
"main": "./lib/parseDomain.js",
"scripts": {
"test": "node node_modules/mocha/bin/mocha -R spec"
"test": "node node_modules/mocha/bin/mocha -R spec",
"build-regex": "node lib/build/buildRegex.js"
},

@@ -9,0 +10,0 @@ "keywords": [

@@ -34,5 +34,5 @@ parse-domain

[![build status](https://travis-ci.org/peerigon/parse-domain.png)](http://travis-ci.org/peerigon/parse-domain)
[![dependencies](https://david-dm.org/peerigon/parse-domain.png)](http://david-dm.org/peerigon/parse-domain)
[![devDependencies](https://david-dm.org/peerigon/parse-domain/dev-status.png)](http://david-dm.org/peerigon/parse-domain#info=devDependencies)
[![Build Status](https://travis-ci.org/peerigon/parse-domain.svg?branch=master)](https://travis-ci.org/peerigon/parse-domain)
[![Dependency Status](https://david-dm.org/peerigon/parse-domain.svg)](https://david-dm.org/peerigon/parse-domain)
[![Coverage Status](https://img.shields.io/coveralls/peerigon/parse-domain.svg)](https://coveralls.io/r/peerigon/parse-domain?branch=master)

@@ -39,0 +39,0 @@ [![browser support](https://ci.testling.com/peerigon/parse-domain.png)

@@ -97,2 +97,3 @@ "use strict";

expect(parseDomain({})).to.equal(null);
expect(parseDomain("")).to.equal(null);
});

@@ -99,0 +100,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc