🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

superhuman-url-regex

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superhuman-url-regex

Regular expression for matching URLs

3.2.0
latest
Source
npm
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
 
Created
Source

url-regex Build Status

Regular expression for matching URLs

Based on this gist by Diego Perini.

Install

$ npm install --save 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

'foo http://github.com bar //google.com'.match(urlRegex());
//=> ['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

Keywords

regex

FAQs

Package last updated on 19 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts