JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1204
  • Score
    100M100P100Q104649F
  • License MIT

Filters valid IPv4 or IPv6 against glob pattern, array, string and etc. If match returns passed `ip`, otherwise null is returned. Have no strict mode to check no IP values.

Package Exports

  • ip-filter

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ip-filter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ip-filter npmjs.com The MIT License

Filters valid IPv4 or IPv6 against glob pattern, array, string and etc. If match returns passed ip, otherwise null is returned. Have no strict mode to check no IP values.

code climate standard code style travis build status coverage status dependency status

You might also be interested in to-object-path, to-file-path or koa-ip-filter.

Install

npm i ip-filter --save

Usage

For more use-cases see the tests

const ipFilter = require('ip-filter')

ipFilter

Filter ip against glob patterns.

Params

  • ip {String}
  • patterns {String|Array|RegExp|Function|Object}: Basically everything that is-match can accept.
  • noStrict {Boolean}: Pass true if want to validate non-ip values.
  • returns {String|null}: If not match returns null, otherwise the passed ip.

Example

var ipFilter = require('ip-filter')

console.log(ipFilter('123.77.34.89', '123.??.34.8*')) // => '123.77.34.89'
console.log(ipFilter('123.222.34.88', '123.??.34.8*')) // => null
console.log(ipFilter('123.222.34.88', ['123.*.34.*', '!123.222.*'])) // => null
console.log(ipFilter('123.222.33.1', ['123.*.34.*', '*.222.33.*'])) // => '123.222.33.1'

// no strict mode
console.log(ipFilter('x-koaip', ['*-koaip', '!foo-koa*'], true)) // => 'x-koaip'
console.log(ipFilter('x-koa.foo', ['*-koa.*', '!foo-koa.*'], true)) // => 'x-koa.foo'

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github