Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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>
  • Loading branch information
aduh95 authored and richardlau committed Mar 29, 2021
commit 2da24ac302167ec346965d92dfe5dea3ee5c9424
10 changes: 10 additions & 0 deletions lib/internal/per_context/primordials.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const {
Symbol,
SymbolIterator,
SymbolToStringTag,
decodeURIComponent,
} = primordials;

const { inspect } = require('internal/util/inspect');
Expand Down
1 change: 1 addition & 0 deletions lib/querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const {
MathAbs,
ObjectCreate,
ObjectKeys,
decodeURIComponent,
} = primordials;

const { Buffer } = require('buffer');
Expand Down
1 change: 1 addition & 0 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const {
ObjectCreate,
ObjectKeys,
SafeSet,
decodeURIComponent,
} = primordials;

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