From c189064eaac75019c75e299b03ea36f79f05dbed Mon Sep 17 00:00:00 2001 From: Joe Portner <5295965+jportner@users.noreply.github.com> Date: Mon, 27 Mar 2023 11:22:25 -0400 Subject: [PATCH] Change approach to shadowing "toString" property for ip module --- lib/ip.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ip.js b/lib/ip.js index 4b2adb5..36dddcb 100644 --- a/lib/ip.js +++ b/lib/ip.js @@ -58,7 +58,7 @@ ip.toBuffer = function (ip, buff, offset) { return result; }; -ip.toString = function (buff, offset, length) { +function ipToString(buff, offset, length) { offset = ~~offset; length = length || (buff.length - offset); @@ -81,6 +81,7 @@ ip.toString = function (buff, offset, length) { return result; }; +Object.defineProperty(ip, 'toString', { value: ipToString, writable: true, enumerable: true, configurable: true }); const ipv4Regex = /^(\d{1,3}\.){3,3}\d{1,3}$/; const ipv6Regex = /^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;