Skip to content

Commit

Permalink
Merge pull request #5 from vasco-santos/fix/ipv4-function-return-value
Browse files Browse the repository at this point in the history
fix: ipv4 function return value
  • Loading branch information
frenchbread authored Nov 29, 2020
2 parents ef75bd5 + 12fe854 commit 59fde62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "private-ip",
"version": "2.1.0",
"version": "2.1.1",
"description": "Check if IP address is private.",
"main": "index.js",
"repository": {
Expand Down
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Netmask = require('netmask').Netmask
const isIp = require('is-ip')

function netmaskCheck (params) {
function ipv4Check (params) {
let privateRanges = [
'0.0.0.0/8',
'10.0.0.0/8',
Expand Down Expand Up @@ -31,6 +31,7 @@ function netmaskCheck (params) {
for (let r of privateRanges) {
if (r.contains(params)) return true
}
return false
}

function ipv6Check (params) {
Expand All @@ -51,7 +52,7 @@ function ipv6Check (params) {

export default (ip) => {
if (isIp.v4(ip) || ip.startsWith('0')) {
return netmaskCheck(ip)
return ipv4Check(ip)
}
return ipv6Check(ip)
}

0 comments on commit 59fde62

Please sign in to comment.