summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine du Hamel <duhamelantoine1995@gmail.com>2021-02-16 14:31:29 +0100
committerRichard Lau <rlau@redhat.com>2021-03-29 12:33:50 +0100
commit2da24ac302167ec346965d92dfe5dea3ee5c9424 (patch)
tree96c34ea3a4e3ae01ddf130ff18262021a8c4c7e4
parent93dd799a864c420c1ce1f9d1bac2ccde7c5ede1d (diff)
downloadnode-new-2da24ac302167ec346965d92dfe5dea3ee5c9424.tar.gz
lib: add URI handling functions to primordials
PR-URL: https://github.com/nodejs/node/pull/37394 Backport-PR-URL: https://github.com/nodejs/node/pull/37859 Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r--lib/internal/per_context/primordials.js10
-rw-r--r--lib/internal/url.js1
-rw-r--r--lib/querystring.js1
-rw-r--r--lib/url.js1
4 files changed, 13 insertions, 0 deletions
diff --git a/lib/internal/per_context/primordials.js b/lib/internal/per_context/primordials.js
index 09bea0fc7f..6a960f36fe 100644
--- a/lib/internal/per_context/primordials.js
+++ b/lib/internal/per_context/primordials.js
@@ -106,6 +106,16 @@ primordials.SafePromise = makeSafe(
class SafePromise extends Promise {}
);
+// Create copies of URI handling functions
+[
+ decodeURI,
+ decodeURIComponent,
+ encodeURI,
+ encodeURIComponent,
+].forEach((fn) => {
+ primordials[fn.name] = fn;
+});
+
// Create copies of the namespace objects
[
'JSON',
diff --git a/lib/internal/url.js b/lib/internal/url.js
index 16f5043df9..2c0b1f518a 100644
--- a/lib/internal/url.js
+++ b/lib/internal/url.js
@@ -14,6 +14,7 @@ const {
Symbol,
SymbolIterator,
SymbolToStringTag,
+ decodeURIComponent,
} = primordials;
const { inspect } = require('internal/util/inspect');
diff --git a/lib/querystring.js b/lib/querystring.js
index 4d196633dc..7bc6684f40 100644
--- a/lib/querystring.js
+++ b/lib/querystring.js
@@ -29,6 +29,7 @@ const {
MathAbs,
ObjectCreate,
ObjectKeys,
+ decodeURIComponent,
} = primordials;
const { Buffer } = require('buffer');
diff --git a/lib/url.js b/lib/url.js
index 735390dfd2..f7dbebea5a 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -25,6 +25,7 @@ const {
ObjectCreate,
ObjectKeys,
SafeSet,
+ decodeURIComponent,
} = primordials;
const { toASCII } = require('internal/idna');