diff --git a/lib/ip.js b/lib/ip.js index 9022443..e7f0920 100644 --- a/lib/ip.js +++ b/lib/ip.js @@ -343,7 +343,7 @@ ip.isLoopback = function (addr) { addr = ip.fromLong(Number(addr)); } - return /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/ + return /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/i .test(addr) || /^0177\./.test(addr) || /^0x7f\./i.test(addr) diff --git a/test/api-test.js b/test/api-test.js index 0db838d..396dcea 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -413,6 +413,12 @@ describe('IP library for node.js', () => { assert.ok(ip.isLoopback('::')); }); }); + + describe('::FFFF:127.0.0.1', () => { + it('should respond with true', () => { + assert.ok(ip.isLoopback('::FFFF:127.0.0.1')); + }); + }); }); describe('address() method', () => {