url-regex
Regular expression for matching URLs
Based on this gist by Diego Perini.
Install
$ npm install --save url-regex
Usage
const urlRegex = ; ;//=> true ;//=> true ;//=> false ;//=> true 'foo http://github.com bar //google.com';//=> ['http://github.com', '//google.com']
API
urlRegex(options)
Returns a regex for matching URLs.
options
exact
Type: boolean
Default: false
(Matches any URL in a string)
Only match an exact string.
Useful with RegExp#test
to check if a string is a URL.
liberal
Type: boolean
Default: false
Match URLs without a protocol, e.g. "foo.com" will match.
License
MIT © Kevin Mårtensson and Diego Perini