Skip to content

Commit

Permalink
lib: add URI handling functions to primordials
Browse files Browse the repository at this point in the history
PR-URL: nodejs#37394
Backport-PR-URL: nodejs#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
1 parent 93dd799 commit 2da24ac
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/internal/per_context/primordials.js
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
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
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
Expand Up @@ -25,6 +25,7 @@ const {
ObjectCreate,
ObjectKeys,
SafeSet,
decodeURIComponent,
} = primordials;

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

0 comments on commit 2da24ac

Please sign in to comment.