Skip to content

Commit 2da24ac

Browse files
aduh95richardlau
authored andcommitted
lib: add URI handling functions to primordials
PR-URL: #37394 Backport-PR-URL: #37859 Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 93dd799 commit 2da24ac

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

lib/internal/per_context/primordials.js

+10
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ primordials.SafePromise = makeSafe(
106106
class SafePromise extends Promise {}
107107
);
108108

109+
// Create copies of URI handling functions
110+
[
111+
decodeURI,
112+
decodeURIComponent,
113+
encodeURI,
114+
encodeURIComponent,
115+
].forEach((fn) => {
116+
primordials[fn.name] = fn;
117+
});
118+
109119
// Create copies of the namespace objects
110120
[
111121
'JSON',

lib/internal/url.js

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
Symbol,
1515
SymbolIterator,
1616
SymbolToStringTag,
17+
decodeURIComponent,
1718
} = primordials;
1819

1920
const { inspect } = require('internal/util/inspect');

lib/querystring.js

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const {
2929
MathAbs,
3030
ObjectCreate,
3131
ObjectKeys,
32+
decodeURIComponent,
3233
} = primordials;
3334

3435
const { Buffer } = require('buffer');

lib/url.js

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const {
2525
ObjectCreate,
2626
ObjectKeys,
2727
SafeSet,
28+
decodeURIComponent,
2829
} = primordials;
2930

3031
const { toASCII } = require('internal/idna');

0 commit comments

Comments
 (0)