Skip to content

FGRibreau/url-is-private

Repository files navigation

url-is-private Build Status

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:ok@localhost.xip.io: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.

About

Check whether or not an url refer to a private IP

Resources

License

Stars

Watchers

Forks

Packages

No packages published