uber-url-regex

5.0.9 • Public • Published

Build Status Greenkeeper badge

url-regex

Regular expression for matching URLs

This is a fork of kevva/url-regex that deals with parenthesis in the end of textual links

Originaly 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
 
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 regex 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 © André Veríssimo, Kevin Mårtensson and Diego Perini

Readme

Keywords

Package Sidebar

Install

npm i uber-url-regex

Weekly Downloads

2

Version

5.0.9

License

MIT

Unpacked Size

5.31 kB

Total Files

4

Last publish

Collaborators

  • averissimo