File tree Expand file tree Collapse file tree 4 files changed +14
-0
lines changed
Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 2424- Fixed some percent encode cases / character sets in the ` URL ` polyfill
2525- Fixed host parsing with ` hostname = host:port ` in the ` URL ` polyfill
2626- Fixed invalid code points handling in UTF-8 decode in the ` URLSearchParams ` polyfill
27+ - Fixed some cases of serialization in ` URL ` polyfill ([ step 3] ( https://url.spec.whatwg.org/#url-serializing ) )
2728- Fixed ` URL ` polyfill ` .origin ` getter with ` blob ` scheme
2829- Fixed a lack of error in ` URLSearchParams.prototype.set ` polyfill on calling only with 1 argument
2930- Fixed handling invalid UTF-8 continuation bytes in ` URLSearchParams ` polyfill
Original file line number Diff line number Diff line change @@ -814,6 +814,7 @@ URLState.prototype = {
814814 output += serializeHost ( host ) ;
815815 if ( port !== null ) output += ':' + port ;
816816 } else if ( scheme === 'file' ) output += '//' ;
817+ if ( host === null && ! url . cannotBeABaseURL && path . length > 1 && path [ 0 ] === '' ) output += '/.' ;
817818 output += url . cannotBeABaseURL ? path [ 0 ] : path . length ? '/' + join ( path , '/' ) : '' ;
818819 if ( query !== null ) output += '?' + query ;
819820 if ( fragment !== null ) output += '#' + fragment ;
Original file line number Diff line number Diff line change @@ -139,6 +139,12 @@ QUnit.test('URL#href', assert => {
139139 // assert.throws(() => new URL('http://zloirock.ru/').href = 'http://a%b', 'forbidden host code point'); // no error in Chrome and FF
140140 // assert.throws(() => new URL('http://zloirock.ru/').href = '1http://zloirock.ru', 'incorrect scheme'); // no error in Chrome
141141 }
142+
143+ // URL serializing step 3 - /. prefix for non-special URLs with null host and path starting with empty segment
144+ assert . same ( new URL ( 'x:/a/..//b' ) . href , 'x:/.//b' , '/. prefix prevents ambiguous serialization' ) ;
145+ assert . same ( new URL ( 'x:/a/..//b' ) . pathname , '//b' , 'pathname is not affected by /. prefix' ) ;
146+ assert . same ( new URL ( 'x:/.//b' ) . href , 'x:/.//b' , '/. prefix is idempotent' ) ;
147+ assert . same ( new URL ( new URL ( 'x:/a/..//b' ) . href ) . pathname , '//b' , '/. prefix round-trips correctly' ) ;
142148} ) ;
143149
144150QUnit . test ( 'URL#origin' , assert => {
Original file line number Diff line number Diff line change @@ -140,6 +140,12 @@ QUnit.test('URL#href', assert => {
140140 // assert.throws(() => new URL('http://zloirock.ru/').href = 'http://a%b', 'forbidden host code point'); // no error in Chrome and FF
141141 // assert.throws(() => new URL('http://zloirock.ru/').href = '1http://zloirock.ru', 'incorrect scheme'); // no error in Chrome
142142 }
143+
144+ // URL serializing step 3 - /. prefix for non-special URLs with null host and path starting with empty segment
145+ assert . same ( new URL ( 'x:/a/..//b' ) . href , 'x:/.//b' , '/. prefix prevents ambiguous serialization' ) ;
146+ assert . same ( new URL ( 'x:/a/..//b' ) . pathname , '//b' , 'pathname is not affected by /. prefix' ) ;
147+ assert . same ( new URL ( 'x:/.//b' ) . href , 'x:/.//b' , '/. prefix is idempotent' ) ;
148+ assert . same ( new URL ( new URL ( 'x:/a/..//b' ) . href ) . pathname , '//b' , '/. prefix round-trips correctly' ) ;
143149} ) ;
144150
145151QUnit . test ( 'URL#origin' , assert => {
You can’t perform that action at this time.
0 commit comments