1.0.0 • Published 5 months ago
is-host-local v1.0.0
is-host-local
A lightweight utility to check if a hostname resolves to a local IP address.
Installation
npm install is-host-local
Usage
TypeScript
import isHostLocal from 'is-host-local';
async function checkHost() {
const result = await isHostLocal('localhost');
console.log(result); // true
const result2 = await isHostLocal('google.com');
console.log(result2); // false
}
JavaScript
const isHostLocal = require('is-host-local').default;
async function checkHost() {
const result = await isHostLocal('localhost');
console.log(result); // true
const result2 = await isHostLocal('google.com');
console.log(result2); // false
}
Return Values
true
: The hostname resolves to a local IP address (127.0.0.1 or private IP ranges)false
: The hostname resolves to a public IP addressnull
: An error occurred while checking the hostname
License
MIT
1.0.0
5 months ago