mirror of
https://github.com/hanzoai/core-js.git
synced 2026-09-24 16:58:15 +00:00
ensure opaque paths always roundtrip in URL polyfill
https://github.com/whatwg/url/pull/844
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# Changelog
|
||||
### Unreleased
|
||||
- Ensure opaque paths always roundtrip in URL polyfill (still without adding to feature detection), [whatwg/url#844](https://github.com/whatwg/url/pull/844)
|
||||
- Fixed possible crash on some keys in `Symbol.for`
|
||||
- Some `get-iterator` / `get-iterator-method` fixes
|
||||
- Fixed `String.prototype.{ match, search }` polyfills conversion order
|
||||
|
||||
@@ -749,7 +749,11 @@ URLState.prototype = {
|
||||
url.fragment = '';
|
||||
state = FRAGMENT;
|
||||
} else if (chr !== EOF) {
|
||||
url.path[0] += percentEncode(chr, C0ControlPercentEncodeSet);
|
||||
if (chr === ' ') {
|
||||
url.path[0] += codePoints[pointer + 1] === '?' || codePoints[pointer + 1] === '#' ? '%20' : ' ';
|
||||
} else {
|
||||
url.path[0] += percentEncode(chr, C0ControlPercentEncodeSet);
|
||||
}
|
||||
} break;
|
||||
|
||||
case QUERY:
|
||||
|
||||
@@ -536,6 +536,16 @@ QUnit.test('URL#search', assert => {
|
||||
// eslint-disable-next-line no-script-url -- safe
|
||||
assert.same(new URL('javascript:void 0').pathname, 'void 0', 'space preserved in opaque pathname');
|
||||
|
||||
// space before query or fragment in opaque paths should be percent-encoded
|
||||
/*
|
||||
assert.same(new URL('x:path ?query').href, 'x:path%20?query', 'space before query in opaque path encoded as %20');
|
||||
assert.same(new URL('x:path ?query').search, '?query', 'query parsed after encoded space');
|
||||
assert.same(new URL('x:path #frag').href, 'x:path%20#frag', 'space before fragment in opaque path encoded as %20');
|
||||
assert.same(new URL('x:path #frag').hash, '#frag', 'fragment parsed after encoded space');
|
||||
assert.same(new URL('x:a b c ?d').pathname, 'a b c%20', 'only space before query encoded');
|
||||
assert.same(new URL('x:a b c #d').pathname, 'a b c%20', 'only space before fragment encoded');
|
||||
*/
|
||||
|
||||
if (DESCRIPTORS) {
|
||||
url = new URL('http://zloirock.ru/?');
|
||||
assert.same(url.search, '');
|
||||
|
||||
@@ -537,6 +537,16 @@ QUnit.test('URL#search', assert => {
|
||||
// eslint-disable-next-line no-script-url -- safe
|
||||
assert.same(new URL('javascript:void 0').pathname, 'void 0', 'space preserved in opaque pathname');
|
||||
|
||||
// space before query or fragment in opaque paths should be percent-encoded
|
||||
/*
|
||||
assert.same(new URL('x:path ?query').href, 'x:path%20?query', 'space before query in opaque path encoded as %20');
|
||||
assert.same(new URL('x:path ?query').search, '?query', 'query parsed after encoded space');
|
||||
assert.same(new URL('x:path #frag').href, 'x:path%20#frag', 'space before fragment in opaque path encoded as %20');
|
||||
assert.same(new URL('x:path #frag').hash, '#frag', 'fragment parsed after encoded space');
|
||||
assert.same(new URL('x:a b c ?d').pathname, 'a b c%20', 'only space before query encoded');
|
||||
assert.same(new URL('x:a b c #d').pathname, 'a b c%20', 'only space before fragment encoded');
|
||||
*/
|
||||
|
||||
if (DESCRIPTORS) {
|
||||
url = new URL('http://zloirock.ru/?');
|
||||
assert.same(url.search, '');
|
||||
|
||||
Reference in New Issue
Block a user