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: #37394
Reviewed-By: Zijian Liu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
aduh95 authored and targos committed Feb 28, 2021
1 parent df538eb commit 856d20b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ rules:
- name: Boolean
- name: DataView
- name: Date
- name: decodeURI
- name: decodeURIComponent
- name: encodeURI
- name: encodeURIComponent
- name: Error
ignore:
- prepareStackTrace
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/freeze_intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ const {
WeakMapPrototype,
WeakSet,
WeakSetPrototype,
decodeURI,
decodeURIComponent,
encodeURI,
encodeURIComponent,
} = primordials;

module.exports = function() {
Expand Down
10 changes: 10 additions & 0 deletions lib/internal/per_context/primordials.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ function copyPrototype(src, dest, prefix) {
}
}

// 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 @@ -30,6 +30,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 @@ -34,6 +34,7 @@ const {
String,
StringPrototypeCharCodeAt,
StringPrototypeSlice,
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 @@ -27,6 +27,7 @@ const {
ObjectKeys,
SafeSet,
StringPrototypeCharCodeAt,
decodeURIComponent,
} = primordials;

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

0 comments on commit 856d20b

Please sign in to comment.