5.0.0 • Published 6 years ago

url-regex v5.0.0

Weekly downloads
632,851
License
MIT
Repository
github
Last release
6 years ago

url-regex Build Status

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

License

MIT © Kevin Mårtensson and Diego Perini

fbg-videos@igpapi/androidframework-dataeat-api@peerio/peerio-icebearpure-validationupstash-redisdropstack-cliviperx-npm@gerhardsletten/get-urlskeef-api@everything-registry/sub-chunk-3023youtube-execytdl-exectbc-vite-plugin-dns-prefetchwhatsthiswindtoday-corevue-helpdeskwebchexeonteams-deploy-notifierteapackage-tatespoorman297spell-check-urlsswiftcrab-clitext-preprocessortianshuai-vite-plugin-dns-prefetchtianbenchu-vite-plugin-dns-prefetchvite-plugin-rehostvite-plugin-tianbenchu-dns-prefetchvite-plugin-dns-prefetch-supervite-plugin-dns-prefetchervite-plugin-prefetch-dns@djaty/djaty-cli@dashup/uijimp-minjimp2is-valid-urljson-schemer-lintjson-to-graphql-clijz-jimpjspeyekap-hide-desktop-iconskaaviokenskens.js@decloudlabs/event-listener-servicevite-plugin-dns-prefetch-mynanibotstylablesolidus-metadatatwitter-utilsty-opentype-detectionts-vpc-lambdatushantitleize-propstovar.jstmdb-clitorrenter@ainasoft/sam-cli@androz2091/instagram-private-api@alibus/gov-open-checker@alisproject/alis-editor@cloudcomponents/cdk-codepipeline-check-parameter-action@codelenny/jimp@bolt/build-slack@decloudlabs/event-listener-service_test@decloudlabs/event-processor-service@decloudlabs/sky-cluster-operator@daviswhitehead/shayr-resourceszig-jimpwebpinfowebpack-dns-prefetchvincent-ok-rich-editorunichat-sharedunplugin-prefetch-dnsurl-buddyurlfind@gun-vue/components@gun-vue/composables@grinchd/instagram-private-api@ethercast/backend-model@functionalfoundry/now-travis@infinitebrahmanuniverse/nolb-url@kryptokoders/evmevents@lagoon/lagu@lhyan/validates@mpotomin/operational-components@mkizka/markdown-it-hatena@jbmoelker/now-travis@jsdevtools/rehype-url-inspector@pwa/manifest@qisong/validates@oopsunome/get-urls@pie-api-gcp/shared@plaa/metascraper-helpers@operational/componentsmetalsmith-dayonendla-scriptspatci-jimp
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