From 37c736f780db7db0b25de15efc700f4083d1b421 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Wed, 1 Mar 2023 08:26:03 -0500 Subject: [PATCH] url: improve `isURLThis` detection PR-URL: https://github.com/nodejs/node/pull/46866 Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca Reviewed-By: Tierney Cyren Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Trivikram Kamat --- lib/internal/url.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/url.js b/lib/internal/url.js index c4640a68b2..3b61f432b9 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -16,6 +16,7 @@ const { ObjectGetOwnPropertySymbols, ObjectGetPrototypeOf, ObjectKeys, + ObjectPrototypeHasOwnProperty, ReflectGetOwnPropertyDescriptor, ReflectOwnKeys, RegExpPrototypeSymbolReplace, @@ -536,8 +537,7 @@ ObjectDefineProperties(URLSearchParams.prototype, { }); function isURLThis(self) { - // TODO(@anonrig): Use ObjectPrototypeHasOwnProperty to avoid prototype look - return (self !== undefined && self !== null && self[context] !== undefined); + return self != null && ObjectPrototypeHasOwnProperty(self, context); } class URL {