5.0.0 • Published 6 years ago
url-regex v5.0.0
url-regex 
Regular expression for matching URLs
Based on this gist by Diego Perini.
Install
$ npm install url-regex
Usage
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
5.0.0
6 years ago
4.1.1
8 years ago
4.1.0
8 years ago
4.0.0
9 years ago
3.2.0
9 years ago
3.1.1
9 years ago
3.1.0
9 years ago
3.0.1
9 years ago
3.0.0
10 years ago
2.1.3
10 years ago
2.1.2
10 years ago
2.1.1
10 years ago
2.1.0
10 years ago
2.0.3
10 years ago
2.0.2
10 years ago
2.0.1
10 years ago
2.0.0
10 years ago
1.0.4
11 years ago
1.0.3
11 years ago
1.0.2
11 years ago
1.0.1
11 years ago
1.0.0
11 years ago