From 886443d16bb8aff0aa5e4e0424650c784c685bcb Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Sat, 28 Nov 2020 21:31:35 +0100 Subject: [PATCH 1/2] fix: ipv4 function return value --- package.json | 2 +- src/index.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d9aed0d..b50bb77 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/index.js b/src/index.js index f54d59d..2c23474 100644 --- a/src/index.js +++ b/src/index.js @@ -31,6 +31,7 @@ function netmaskCheck (params) { for (let r of privateRanges) { if (r.contains(params)) return true } + return false } function ipv6Check (params) { From 12fe8546d143275cc2550acc2eaa11633533f3bf Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Sun, 29 Nov 2020 12:55:54 +0100 Subject: [PATCH 2/2] chore: rename ipv4 check function --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 2c23474..9e7f93b 100644 --- a/src/index.js +++ b/src/index.js @@ -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', @@ -52,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) }