summaryrefslogtreecommitdiff
path: root/lib/internal/url.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-11-07 15:58:51 +0800
committerRich Trott <rtrott@gmail.com>2018-11-09 15:53:32 -0800
commit5e1bf058f4906c0a49c34c6a1353d0b34784c80a (patch)
tree272b21650916fe653b11f18eb6dca277e6b261d5 /lib/internal/url.js
parent457cde3167ec474aa57948a2b1fa58e9c4a55f4c (diff)
downloadandroid-node-v8-5e1bf058f4906c0a49c34c6a1353d0b34784c80a.tar.gz
android-node-v8-5e1bf058f4906c0a49c34c6a1353d0b34784c80a.tar.bz2
android-node-v8-5e1bf058f4906c0a49c34c6a1353d0b34784c80a.zip
url: make the context non-enumerable
At the moment we expose the context as a normal property on the prototype chain of URL or take them from the base URL which makes them enumerable and considered by assert libraries even though the context carries path-dependent information that do not affect the equivalence of these objects. This patch fixes it in a minimal manner by marking the context non-enumerable as making it full private would require more refactoring and can be done in a bigger patch later. PR-URL: https://github.com/nodejs/node/pull/24218 Refs: https://github.com/nodejs/node/issues/24211 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Diffstat (limited to 'lib/internal/url.js')
-rw-r--r--lib/internal/url.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/internal/url.js b/lib/internal/url.js
index 518c745b41..693f082aed 100644
--- a/lib/internal/url.js
+++ b/lib/internal/url.js
@@ -245,7 +245,14 @@ function onParseError(flags, input) {
// Reused by URL constructor and URL#href setter.
function parse(url, input, base) {
const base_context = base ? base[context] : undefined;
- url[context] = new URLContext();
+ // In the URL#href setter
+ if (!url[context]) {
+ Object.defineProperty(url, context, {
+ enumerable: false,
+ configurable: false,
+ value: new URLContext()
+ });
+ }
_parse(input.trim(), -1, base_context, undefined,
onParseComplete.bind(url), onParseError);
}
@@ -1437,7 +1444,11 @@ function toPathIfFileURL(fileURLOrPath) {
}
function NativeURL(ctx) {
- this[context] = ctx;
+ Object.defineProperty(this, context, {
+ enumerable: false,
+ configurable: false,
+ value: ctx
+ });
}
NativeURL.prototype = URL.prototype;