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

url-regex

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

url-regex - npm Package Compare versions

Comparing version 1.0.4 to 2.0.0

LICENSE.md

25

index.js
'use strict';
var tlds = require('./tlds.json').join('|');
/**

@@ -10,3 +12,24 @@ * Regular expression for matching URLs

module.exports = function () {
return /(?:^|\s)(["'])?(?:(?:(?:(?:https?|ftp|\w):)?\/\/)|(?:www.))(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?\1/ig;
var auth = '(?:\\S+(?::\\S*)?@)?';
var domain = '(?:\\.(?:xn--[a-z0-9\\-]{1,59}|(?:[a-z\\u00a1-\\uffff0-9]+-?){0,62}[a-z\\u00a1-\\uffff0-9]{1,63}))*';
var host = '(?:xn--[a-z0-9\\-]{1,59}|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?){0,62}[a-z\\u00a1-\\uffff0-9]{1,63}))';
var path = '(?:/[^\\s]*)?';
var port = '(?::\\d{2,5})?';
var protocol = '(?:(?:(?:https?|ftp):)?\/\/)?';
var tld = '(?:\\.(?:xn--[a-z0-9\\-]{1,59}|' + tlds + '+))';
var ips = [
'(?!10(?:\\.\\d{1,3}){3})',
'(?!127(?:\\.\\d{1,3}){3})',
'(?!169\\.254(?:\\.\\d{1,3}){2})',
'(?!192\\.168(?:\\.\\d{1,3}){2})',
'(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})',
'(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])',
'(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}',
'(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))'
].join('');
return new RegExp([
'(?:^|\\s)(["\'])?' + protocol + auth + '(?:' + ips + '|',
'(?:localhost)|' + host + domain + tld + ')' + port + path + '\\1'
].join(''), 'ig');
};

13

package.json
{
"name": "url-regex",
"version": "1.0.4",
"version": "2.0.0",
"description": "Regular expression for matching URLs",

@@ -16,6 +16,9 @@ "license": "MIT",

"scripts": {
"prepublish": "node lib/index.js",
"pretest": "node lib/index.js",
"test": "node test.js"
},
"files": [
"index.js"
"index.js",
"tlds.json"
],

@@ -27,5 +30,9 @@ "keywords": [

],
"dependencies": {
"ip-regex": "^1.0.0"
},
"devDependencies": {
"ava": "0.0.4"
"ava": "^0.0.4",
"tlds": "^1.14.0"
}
}
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