Package Exports
- is-local-address
- is-local-address/ipv4
- is-local-address/ipv6
Readme
is-local-address
Regex for matching localhost alike URLs.
Note: There are Bogon IP address ranges not covered by this regex.
The intention of this package is to cover some of the most common cases.
If you need a more sophisticated solution, check is-localhost-ip.
Install
$ npm install is-local-address --save
Usage
The method exported by default supports IPv4 and IPv6 detection:
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 require the specific 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