url-is-private
v2.0.1
Published
Check whether or not a url hostname refers to a private IP
Downloads
16
Readme
url-is-private
Check whether or not a url hostname refers to a private IP
Setup
npm install url-is-private
Usage
isPrivate(hostname: {String}, f: (err : {Error,Null}, isPrivate: {Boolean}))
var isPrivate = require('url-is-private').isPrivate;
isPrivate('http://127.0.0.1.xip.io', function(err, isPrivate){
console.log(err === null, isPrivate == true);
});
isPrivate('myprotocol://auth@localhost', function(err, isPrivate){
console.log(err === null, isPrivate === true);
});
isPrivate('https://google.com', function(err, isPrivate){
console.log(err === null, isPrivate === false);
});
isPrivateIncludingPublicIp(hostname: {String}, f: (err : {Error,Null}, isPrivateIncludingPublicIp: {Boolean}))
var isPrivateIncludingPublicIp = require('url-is-private').isPrivateIncludingPublicIp;
isPrivateIncludingPublicIp('YOUR-PUBLIC-IP.xip.io', function(err, isPrivate){
console.log(err === null, isPrivate == true);
});
isPrivate('http://ok:[email protected]:293/', function(err, isPrivate){
console.log(err === null, isPrivate === true);
});
isPrivate('http://google.com/', function(err, isPrivate){
console.log(err === null, isPrivate === false);
});
How it works
url-is-private uses hostname-is-private underneath.