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');
urlRegex().test('www.github.com foo bar');
urlRegex({exact: true}).test('http://github.com foo bar');
urlRegex({exact: true}).test('http://github.com');
urlRegex({strict: false}).test('github.com foo bar');
urlRegex({exact: true, strict: false}).test('github.com');
'foo http://github.com bar //google.com'.match(urlRegex());
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
License
MIT © Kevin Mårtensson and Diego Perini