New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

url-regex

Package Overview
Dependencies
Maintainers
2
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 3.2.0 to 4.0.0

28

index.js
'use strict';
var ipRegex = require('ip-regex');
const ipRegex = require('ip-regex');
module.exports = function (opts) {
module.exports = opts => {
opts = opts || {};
var protocol = '(?:(?:[a-z]+:)?//)';
var auth = '(?:\\S+(?::\\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 path = '(?:[/?#][^\\s"]*)?';
var regex = [
'(?:' + protocol + '|www\\.)' + auth, '(?:localhost|' + ip + '|' + host + domain + tld + ')',
port, path
].join('');
const protocol = '(?:(?:[a-z]+:)?//)';
const auth = '(?:\\S+(?::\\S*)?@)?';
const ip = ipRegex.v4().source;
const host = '(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)';
const domain = '(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*';
const tld = '(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?';
const port = '(?::\\d{2,5})?';
const path = '(?:[/?#][^\\s"]*)?';
const regex = `(?:${protocol}|www\\.)${auth}(?:localhost|${ip}|${host}${domain}${tld})${port}${path}`;
return opts.exact ? new RegExp('(?:^' + regex + '$)', 'i') :
new RegExp(regex, 'ig');
return opts.exact ? new RegExp(`(?:^${regex}$)`, 'i') : new RegExp(regex, 'ig');
};
{
"name": "url-regex",
"version": "3.2.0",
"version": "4.0.0",
"description": "Regular expression for matching URLs",

@@ -13,3 +13,3 @@ "license": "MIT",

"engines": {
"node": ">=0.10.0"
"node": ">=4"
},

@@ -33,8 +33,3 @@ "scripts": {

"xo": "*"
},
"xo": {
"ignores": [
"test.js"
]
}
}

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

```js
var urlRegex = require('url-regex');
const urlRegex = require('url-regex');

@@ -48,7 +48,6 @@ urlRegex().test('http://github.com foo bar');

Type: `boolean`
Default: `false` *(Matches any URL in a string)*
Type: `boolean`<br>
Default: `false`
Only match an exact string.
Useful with `RegExp#test` to check if a string is a URL.
Only match an exact string. Useful with `RegExp#test` to check if a string is a URL.

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