summaryrefslogtreecommitdiff
path: root/lib/url.js
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2019-11-22 18:04:46 +0100
committerMichaël Zasso <targos@protonmail.com>2019-11-25 10:28:15 +0100
commit0646eda4fc0affb98e13c30acb522e63b7fd6dde (patch)
tree078209f50b044e24ea2c72cbbe7dca6e34bb7e25 /lib/url.js
parent35c6e0cc2b56a5380e6808ef5603ecc2b167e032 (diff)
downloadandroid-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.tar.gz
android-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.tar.bz2
android-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.zip
lib: flatten access to primordials
Store all primordials as properties of the primordials object. Static functions are prefixed by the constructor's name and prototype methods are prefixed by the constructor's name followed by "Prototype". For example: primordials.Object.keys becomes primordials.ObjectKeys. PR-URL: https://github.com/nodejs/node/pull/30610 Refs: https://github.com/nodejs/node/issues/29766 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'lib/url.js')
-rw-r--r--lib/url.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/url.js b/lib/url.js
index fc3863f6ef..316b2a12ee 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -21,7 +21,11 @@
'use strict';
-const { Object, SafeSet } = primordials;
+const {
+ ObjectCreate,
+ ObjectKeys,
+ SafeSet,
+} = primordials;
const { toASCII } = require('internal/idna');
const { encodeStr, hexTable } = require('internal/querystring');
@@ -248,7 +252,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
}
} else if (parseQueryString) {
this.search = null;
- this.query = Object.create(null);
+ this.query = ObjectCreate(null);
}
return this;
}
@@ -437,7 +441,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
} else if (parseQueryString) {
// No query string, but parseQueryString still requested
this.search = null;
- this.query = Object.create(null);
+ this.query = ObjectCreate(null);
}
const useQuestionIdx =
@@ -677,7 +681,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
}
const result = new Url();
- const tkeys = Object.keys(this);
+ const tkeys = ObjectKeys(this);
for (let tk = 0; tk < tkeys.length; tk++) {
const tkey = tkeys[tk];
result[tkey] = this[tkey];
@@ -696,7 +700,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
// Hrefs like //foo/bar always cut to the protocol.
if (relative.slashes && !relative.protocol) {
// Take everything except the protocol from relative
- const rkeys = Object.keys(relative);
+ const rkeys = ObjectKeys(relative);
for (let rk = 0; rk < rkeys.length; rk++) {
const rkey = rkeys[rk];
if (rkey !== 'protocol')
@@ -723,7 +727,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
// because that's known to be hostless.
// anything else is assumed to be absolute.
if (!slashedProtocol.has(relative.protocol)) {
- const keys = Object.keys(relative);
+ const keys = ObjectKeys(relative);
for (let v = 0; v < keys.length; v++) {
const k = keys[v];
result[k] = relative[k];