@keep-lts/url-regex
v5.0.1
Published
Security-maintained drop-in fork of url-regex. Patches CVE-2020-7661 (ReDoS) by rewriting the host/domain sub-patterns to run in linear time — pure JS, no native dependency. Original API unchanged.
Maintainers
Readme
@keep-lts/url-regex
Security-maintained, drop-in fork of
url-regex.
[!IMPORTANT] Unofficial security-maintenance fork. The original
url-regexhas no fix for CVE-2020-7661 / GHSA-v4rh-8p82-6h5w (High). This fork applies a minimal, tested patch and keeps the public API byte-for-byte compatible. Adopt with zero code changes via npmoverrides:{ "overrides": { "url-regex": "npm:@keep-lts/url-regex@^5.0.1" } }See SECURITY.md and CHANGELOG.md. Original functionality and attribution preserved under the MIT license.
url-regex 
Regular expression for matching URLs
Based on this gist by Diego Perini.
Install
$ npm install url-regexUsage
const urlRegex = require('url-regex');
urlRegex().test('http://github.com foo bar');
//=> true
urlRegex().test('www.github.com foo bar');
//=> true
urlRegex({exact: true}).test('http://github.com foo bar');
//=> false
urlRegex({exact: true}).test('http://github.com');
//=> true
urlRegex({strict: false}).test('github.com foo bar');
//=> true
urlRegex({exact: true, strict: false}).test('github.com');
//=> true
'foo http://github.com bar //google.com'.match(urlRegex());
//=> ['http://github.com', '//google.com']API
urlRegex([options])
Returns a RegExp for matching URLs.
options
exact
Type: boolean
Default: false
Only match an exact string. Useful with RegExp#test to check if a string is a URL.
strict
Type: boolean
Default: true
Force URLs to start with a valid protocol or www. If set to false it'll match the TLD against a list of valid TLDs.
Related
- get-urls - Get all URLs in text
- linkify-urls - Linkify URLs in text
License
MIT © Kevin Mårtensson and Diego Perini
