JSPM

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

Static check if a hostname is a local IP address.

Package Exports

  • is-local-address
  • is-local-address/ipv4
  • is-local-address/ipv6

Readme

is-local-address

Check if an URL hostname is a local address, including support for Bogon IP address ranges.

Most solutions typically determine local IP addresses by checking DNS.

However, this implementation uses the Bogon IP address specification, delivering performance five times faster than alternative approaches.

Check benchmark for detailed performance metrics.

Install

$ npm install is-local-address --save

Usage

The method exported by default supports detection of both IPv4 and IPv6 addresses:

const isLocalAddress = require('is-local-address')

isLocalAddress(new URL('https://127.0.0.1').hostname) // true
isLocalAddress(new URL('http://[::]:3000').hostname) // true

You can also specify to just resolve IPv4:

const isLocalAddress = require('is-local-address/ipv4')
isLocalAddress(new URL('https://127.0.0.1').hostname) // true

or just IPv6:

const isLocalAddress = require('is-local-address/ipv6')
isLocalAddress(new URL('http://[::]:3000').hostname) // true

License

is-local-address © Kiko Beats, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.

kikobeats.com · GitHub Kiko Beats · X @Kikobeats