Socket
Book a DemoInstallSign in
Socket

port-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

port-regex

Regular expression for matching ports

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

port-regex Build Status

Regular expression for matching ports

Install

$ npm install --save port-regex

Usage

const portRegex = require('port-regex');

portRegex().test('http://github.com:80');
//=> true

portRegex().test('127:0.0.1:3000');
//=> true

portRegex({exact: true}).test('http://github.com:80');
//=> false

portRegex({exact: true}).test(':3000');
//=> true

'http://github.com:80 127:0.0.1:3000'.match(portRegex());
//=> [':80', ':3000']

API

portRegex([options])

exact

Type: boolean
Default: false

Only match an exact string. Useful with RegExp#test to check if a string is a port.

License

MIT © Kevin Martensson

Keywords

port

FAQs

Package last updated on 31 May 2017

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