@@ -26,6 +26,7 @@ const {
2626 StringPrototypeIndexOf,
2727 StringPrototypeSlice,
2828 StringPrototypeStartsWith,
29+ StringPrototypeToWellFormed,
2930 Symbol,
3031 SymbolIterator,
3132 SymbolToStringTag,
@@ -42,7 +43,6 @@ const {
4243const {
4344 getConstructorOf,
4445 removeColors,
45- toUSVString,
4646 kEnumerableProperty,
4747 SideEffectFreeRegExpPrototypeSymbolReplace,
4848} = require ( 'internal/util' ) ;
@@ -360,7 +360,11 @@ class URLSearchParams {
360360 throw new ERR_INVALID_TUPLE ( 'Each query pair' , '[name, value]' ) ;
361361 }
362362 // Append (innerSequence[0], innerSequence[1]) to querys list.
363- ArrayPrototypePush ( this . #searchParams, toUSVString ( pair [ 0 ] ) , toUSVString ( pair [ 1 ] ) ) ;
363+ ArrayPrototypePush (
364+ this . #searchParams,
365+ StringPrototypeToWellFormed ( `${ pair [ 0 ] } ` ) ,
366+ StringPrototypeToWellFormed ( `${ pair [ 1 ] } ` ) ,
367+ ) ;
364368 } else {
365369 if ( ( ( typeof pair !== 'object' && typeof pair !== 'function' ) ||
366370 typeof pair [ SymbolIterator ] !== 'function' ) ) {
@@ -371,7 +375,7 @@ class URLSearchParams {
371375
372376 for ( const element of pair ) {
373377 length ++ ;
374- ArrayPrototypePush ( this . #searchParams, toUSVString ( element ) ) ;
378+ ArrayPrototypePush ( this . #searchParams, StringPrototypeToWellFormed ( ` ${ element } ` ) ) ;
375379 }
376380
377381 // If innerSequence's size is not 2, then throw a TypeError.
@@ -389,8 +393,8 @@ class URLSearchParams {
389393 const key = keys [ i ] ;
390394 const desc = ReflectGetOwnPropertyDescriptor ( init , key ) ;
391395 if ( desc !== undefined && desc . enumerable ) {
392- const typedKey = toUSVString ( key ) ;
393- const typedValue = toUSVString ( init [ key ] ) ;
396+ const typedKey = StringPrototypeToWellFormed ( key ) ;
397+ const typedValue = StringPrototypeToWellFormed ( ` ${ init [ key ] } ` ) ;
394398
395399 // Two different keys may become the same USVString after normalization.
396400 // In that case, we retain the later one. Refer to WPT.
@@ -407,7 +411,7 @@ class URLSearchParams {
407411 }
408412 } else {
409413 // https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
410- init = toUSVString ( init ) ;
414+ init = StringPrototypeToWellFormed ( ` ${ init } ` ) ;
411415 this . #searchParams = init ? parseParams ( init ) : [ ] ;
412416 }
413417 }
@@ -462,8 +466,8 @@ class URLSearchParams {
462466 throw new ERR_MISSING_ARGS ( 'name' , 'value' ) ;
463467 }
464468
465- name = toUSVString ( name ) ;
466- value = toUSVString ( value ) ;
469+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
470+ value = StringPrototypeToWellFormed ( ` ${ value } ` ) ;
467471 ArrayPrototypePush ( this . #searchParams, name , value ) ;
468472 if ( this . #context) {
469473 this . #context. search = this . toString ( ) ;
@@ -479,10 +483,10 @@ class URLSearchParams {
479483 }
480484
481485 const list = this . #searchParams;
482- name = toUSVString ( name ) ;
486+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
483487
484488 if ( value !== undefined ) {
485- value = toUSVString ( value ) ;
489+ value = StringPrototypeToWellFormed ( ` ${ value } ` ) ;
486490 for ( let i = 0 ; i < list . length ; ) {
487491 if ( list [ i ] === name && list [ i + 1 ] === value ) {
488492 list . splice ( i , 2 ) ;
@@ -513,7 +517,7 @@ class URLSearchParams {
513517 }
514518
515519 const list = this . #searchParams;
516- name = toUSVString ( name ) ;
520+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
517521 for ( let i = 0 ; i < list . length ; i += 2 ) {
518522 if ( list [ i ] === name ) {
519523 return list [ i + 1 ] ;
@@ -532,7 +536,7 @@ class URLSearchParams {
532536
533537 const list = this . #searchParams;
534538 const values = [ ] ;
535- name = toUSVString ( name ) ;
539+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
536540 for ( let i = 0 ; i < list . length ; i += 2 ) {
537541 if ( list [ i ] === name ) {
538542 values . push ( list [ i + 1 ] ) ;
@@ -550,10 +554,10 @@ class URLSearchParams {
550554 }
551555
552556 const list = this . #searchParams;
553- name = toUSVString ( name ) ;
557+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
554558
555559 if ( value !== undefined ) {
556- value = toUSVString ( value ) ;
560+ value = StringPrototypeToWellFormed ( ` ${ value } ` ) ;
557561 }
558562
559563 for ( let i = 0 ; i < list . length ; i += 2 ) {
@@ -576,8 +580,8 @@ class URLSearchParams {
576580 }
577581
578582 const list = this . #searchParams;
579- name = toUSVString ( name ) ;
580- value = toUSVString ( value ) ;
583+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
584+ value = StringPrototypeToWellFormed ( ` ${ value } ` ) ;
581585
582586 // If there are any name-value pairs whose name is `name`, in `list`, set
583587 // the value of the first such name-value pair to `value` and remove the
@@ -765,7 +769,7 @@ class URL {
765769 throw new ERR_MISSING_ARGS ( 'url' ) ;
766770 }
767771
768- // toUSVString is not needed.
772+ // StringPrototypeToWellFormed is not needed.
769773 input = `${ input } ` ;
770774
771775 if ( base !== undefined ) {
@@ -998,7 +1002,7 @@ class URL {
9981002 }
9991003
10001004 set search ( value ) {
1001- const href = bindingUrl . update ( this . #context. href , updateActions . kSearch , toUSVString ( value ) ) ;
1005+ const href = bindingUrl . update ( this . #context. href , updateActions . kSearch , StringPrototypeToWellFormed ( ` ${ value } ` ) ) ;
10021006 if ( href ) {
10031007 this . #updateContext( href ) ;
10041008 }
@@ -1289,15 +1293,15 @@ function domainToASCII(domain) {
12891293 if ( arguments . length < 1 )
12901294 throw new ERR_MISSING_ARGS ( 'domain' ) ;
12911295
1292- // toUSVString is not needed.
1296+ // StringPrototypeToWellFormed is not needed.
12931297 return bindingUrl . domainToASCII ( `${ domain } ` ) ;
12941298}
12951299
12961300function domainToUnicode ( domain ) {
12971301 if ( arguments . length < 1 )
12981302 throw new ERR_MISSING_ARGS ( 'domain' ) ;
12991303
1300- // toUSVString is not needed.
1304+ // StringPrototypeToWellFormed is not needed.
13011305 return bindingUrl . domainToUnicode ( `${ domain } ` ) ;
13021306}
13031307
@@ -1493,7 +1497,6 @@ function getURLOrigin(url) {
14931497}
14941498
14951499module . exports = {
1496- toUSVString,
14971500 fileURLToPath,
14981501 pathToFileURL,
14991502 toPathIfFileURL,
0 commit comments