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 2.1.3 to 3.0.0

19

index.js
'use strict';
var ip = require('ip-regex').v4().source;
var tlds = require('./tlds.json').join('|');
var ipRegex = require('ip-regex');

@@ -8,13 +7,13 @@ module.exports = function (opts) {

var protocol = '(?:(?:[a-z]+:)?//)';
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 ip = ipRegex.v4().source;
var host = '(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)';
var domain = '(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*';
var tld = '(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))';
var port = '(?::\\d{2,5})?';
var protocol = '(?:(?:(?:\\w)+:)?\/\/)?';
var tld = '(?:\\.(?:xn--[a-z0-9\\-]{1,59}|' + tlds + '+))';
var path = '(?:/\\S*)?';
var regex = [
protocol + auth + '(?:' + ip + '|',
'(?:localhost)|' + host + domain + tld + ')' + port + path
protocol, auth, '(?:localhost|' + ip + '|' + host + domain + tld + ')',
port, path
].join('');

@@ -21,0 +20,0 @@

{
"name": "url-regex",
"version": "2.1.3",
"version": "3.0.0",
"description": "Regular expression for matching URLs",

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

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

@@ -34,5 +31,4 @@ "keywords": [

"devDependencies": {
"ava": "^0.0.4",
"tlds": "^1.14.0"
"ava": "^0.0.4"
}
}

@@ -20,13 +20,13 @@ # url-regex [![Build Status](http://img.shields.io/travis/kevva/url-regex.svg?style=flat)](https://travis-ci.org/kevva/url-regex)

urlRegex().test('github.com foo bar');
urlRegex().test('http://github.com foo bar');
//=> true
urlRegex({exact: true}).test('github.com foo bar');
urlRegex({exact: true}).test('http://github.com foo bar');
//=> false
urlRegex({exact: true}).test('github.com');
urlRegex({exact: true}).test('http://github.com');
//=> true
'foo github.com bar google.com'.match(urlRegex());
//=> ['github.com', 'google.com']
'foo http://github.com bar //google.com'.match(urlRegex());
//=> ['http://github.com', '//google.com']
```

@@ -33,0 +33,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