diff --git a/lib/internal/per_context/primordials.js b/lib/internal/per_context/primordials.js index 09bea0fc7fc523..6a960f36feda45 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 16f5043df9c641..2c0b1f518a7091 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 4d196633dcf2c7..7bc6684f400174 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 735390dfd2e59b..f7dbebea5ac125 100644 --- a/lib/url.js +++ b/lib/url.js @@ -25,6 +25,7 @@ const { ObjectCreate, ObjectKeys, SafeSet, + decodeURIComponent, } = primordials; const { toASCII } = require('internal/idna');