Skip to content

Commit 856d20b

Browse files
aduh95targos
authored andcommitted
lib: add URI handling functions to primordials
PR-URL: #37394 Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent df538eb commit 856d20b

File tree

6 files changed

+21
-0
lines changed

6 files changed

+21
-0
lines changed

lib/.eslintrc.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ rules:
3838
- name: Boolean
3939
- name: DataView
4040
- name: Date
41+
- name: decodeURI
42+
- name: decodeURIComponent
43+
- name: encodeURI
44+
- name: encodeURIComponent
4145
- name: Error
4246
ignore:
4347
- prepareStackTrace

lib/internal/freeze_intrinsics.js

+4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ const {
107107
WeakMapPrototype,
108108
WeakSet,
109109
WeakSetPrototype,
110+
decodeURI,
111+
decodeURIComponent,
112+
encodeURI,
113+
encodeURIComponent,
110114
} = primordials;
111115

112116
module.exports = function() {

lib/internal/per_context/primordials.js

+10
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ function copyPrototype(src, dest, prefix) {
137137
}
138138
}
139139

140+
// Create copies of URI handling functions
141+
[
142+
decodeURI,
143+
decodeURIComponent,
144+
encodeURI,
145+
encodeURIComponent,
146+
].forEach((fn) => {
147+
primordials[fn.name] = fn;
148+
});
149+
140150
// Create copies of the namespace objects
141151
[
142152
'JSON',

lib/internal/url.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const {
3030
Symbol,
3131
SymbolIterator,
3232
SymbolToStringTag,
33+
decodeURIComponent,
3334
} = primordials;
3435

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

lib/querystring.js

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const {
3434
String,
3535
StringPrototypeCharCodeAt,
3636
StringPrototypeSlice,
37+
decodeURIComponent,
3738
} = primordials;
3839

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

lib/url.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const {
2727
ObjectKeys,
2828
SafeSet,
2929
StringPrototypeCharCodeAt,
30+
decodeURIComponent,
3031
} = primordials;
3132

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

0 commit comments

Comments
 (0)