Skip to content

Commit 0d14a1b

Browse files
committed
fix some cases of chars case in escape polyfill
1 parent 3a28ddc commit 0d14a1b

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Fixed (updated following the final spec) one more case `Set.prototype.difference` polyfill with updating `this`
1717
- Fixed `DataView.prototype.setFloat16` polyfill in (0, 1) range
1818
- Fixed order of arguments validation in `String.prototype.{ startsWith, endsWith }` polyfills
19+
- Fixed some cases of chars case in `escape` polyfill
1920
- Fixed named backreferences in `RegExp` NCG polyfill
2021
- Fixed some cases of `RegExp` NCG polyfill in combination with other types of groups
2122
- Fixed some cases of `RegExp` NCG polyfill in combination with `dotAll`

packages/core-js/modules/es.escape.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $({ global: true }, {
3333
} else {
3434
code = charCodeAt(chr, 0);
3535
if (code < 256) {
36-
result += '%' + hex(code, 2);
36+
result += '%' + toUpperCase(hex(code, 2));
3737
} else {
3838
result += '%u' + toUpperCase(hex(code, 4));
3939
}

tests/unit-global/es.escape.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ QUnit.test('escape', assert => {
44
assert.arity(escape, 1);
55
assert.looksNative(escape);
66
assert.same(escape('!q2ф'), '%21q2%u0444');
7+
assert.same(escape('\n'), '%0A', 'percent encoding uses uppercase hex digits');
8+
assert.same(escape('\u0001'), '%01', 'low code points use uppercase hex');
9+
assert.same(escape('\u00FF'), '%FF', 'code < 256 uses uppercase hex');
710
assert.same(escape(null), 'null');
811
assert.same(escape(undefined), 'undefined');
912

tests/unit-pure/es.escape.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ QUnit.test('escape', assert => {
44
assert.isFunction(escape);
55
assert.arity(escape, 1);
66
assert.same(escape('!q2ф'), '%21q2%u0444');
7+
assert.same(escape('\n'), '%0A', 'percent encoding uses uppercase hex digits');
8+
assert.same(escape('\u0001'), '%01', 'low code points use uppercase hex');
9+
assert.same(escape('\u00FF'), '%FF', 'code < 256 uses uppercase hex');
710
assert.same(escape(null), 'null');
811
assert.same(escape(undefined), 'undefined');
912

0 commit comments

Comments
 (0)