From 4d0faf4ddc10bd8155dde1dfd19bbf1562a2c7dd 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/internal/url.js b/lib/internal/url.js index ea5cacf30b657b..e23afe3f93e632 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -17,6 +17,7 @@ const { ObjectGetOwnPropertySymbols, ObjectGetPrototypeOf, ObjectKeys, + ObjectPrototypeHasOwnProperty, ReflectApply, ReflectGetOwnPropertyDescriptor, ReflectOwnKeys, @@ -568,6 +569,10 @@ function onParseComplete(flags, protocol, username, password, initSearchParams(this[searchParams], query); } +function isURLThis(self) { + return self != null && ObjectPrototypeHasOwnProperty(self, context); +} + function onParseError(input, flags) { throw new ERR_INVALID_URL(input); }