@@ -26,6 +26,7 @@ const {
26
26
StringPrototypeIndexOf,
27
27
StringPrototypeSlice,
28
28
StringPrototypeStartsWith,
29
+ StringPrototypeToWellFormed,
29
30
Symbol,
30
31
SymbolIterator,
31
32
SymbolToStringTag,
@@ -42,7 +43,6 @@ const {
42
43
const {
43
44
getConstructorOf,
44
45
removeColors,
45
- toUSVString,
46
46
kEnumerableProperty,
47
47
SideEffectFreeRegExpPrototypeSymbolReplace,
48
48
} = require ( 'internal/util' ) ;
@@ -366,7 +366,11 @@ class URLSearchParams {
366
366
throw new ERR_INVALID_TUPLE ( 'Each query pair' , '[name, value]' ) ;
367
367
}
368
368
// Append (innerSequence[0], innerSequence[1]) to querys list.
369
- ArrayPrototypePush ( this . #searchParams, toUSVString ( pair [ 0 ] ) , toUSVString ( pair [ 1 ] ) ) ;
369
+ ArrayPrototypePush (
370
+ this . #searchParams,
371
+ StringPrototypeToWellFormed ( `${ pair [ 0 ] } ` ) ,
372
+ StringPrototypeToWellFormed ( `${ pair [ 1 ] } ` ) ,
373
+ ) ;
370
374
} else {
371
375
if ( ( ( typeof pair !== 'object' && typeof pair !== 'function' ) ||
372
376
typeof pair [ SymbolIterator ] !== 'function' ) ) {
@@ -377,7 +381,7 @@ class URLSearchParams {
377
381
378
382
for ( const element of pair ) {
379
383
length ++ ;
380
- ArrayPrototypePush ( this . #searchParams, toUSVString ( element ) ) ;
384
+ ArrayPrototypePush ( this . #searchParams, StringPrototypeToWellFormed ( ` ${ element } ` ) ) ;
381
385
}
382
386
383
387
// If innerSequence's size is not 2, then throw a TypeError.
@@ -395,8 +399,8 @@ class URLSearchParams {
395
399
const key = keys [ i ] ;
396
400
const desc = ReflectGetOwnPropertyDescriptor ( init , key ) ;
397
401
if ( desc !== undefined && desc . enumerable ) {
398
- const typedKey = toUSVString ( key ) ;
399
- const typedValue = toUSVString ( init [ key ] ) ;
402
+ const typedKey = StringPrototypeToWellFormed ( key ) ;
403
+ const typedValue = StringPrototypeToWellFormed ( ` ${ init [ key ] } ` ) ;
400
404
401
405
// Two different keys may become the same USVString after normalization.
402
406
// In that case, we retain the later one. Refer to WPT.
@@ -413,7 +417,7 @@ class URLSearchParams {
413
417
}
414
418
} else {
415
419
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
416
- init = toUSVString ( init ) ;
420
+ init = StringPrototypeToWellFormed ( ` ${ init } ` ) ;
417
421
this . #searchParams = init ? parseParams ( init ) : [ ] ;
418
422
}
419
423
}
@@ -468,8 +472,8 @@ class URLSearchParams {
468
472
throw new ERR_MISSING_ARGS ( 'name' , 'value' ) ;
469
473
}
470
474
471
- name = toUSVString ( name ) ;
472
- value = toUSVString ( value ) ;
475
+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
476
+ value = StringPrototypeToWellFormed ( ` ${ value } ` ) ;
473
477
ArrayPrototypePush ( this . #searchParams, name , value ) ;
474
478
if ( this . #context) {
475
479
this . #context. search = this . toString ( ) ;
@@ -485,10 +489,10 @@ class URLSearchParams {
485
489
}
486
490
487
491
const list = this . #searchParams;
488
- name = toUSVString ( name ) ;
492
+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
489
493
490
494
if ( value !== undefined ) {
491
- value = toUSVString ( value ) ;
495
+ value = StringPrototypeToWellFormed ( ` ${ value } ` ) ;
492
496
for ( let i = 0 ; i < list . length ; ) {
493
497
if ( list [ i ] === name && list [ i + 1 ] === value ) {
494
498
list . splice ( i , 2 ) ;
@@ -519,7 +523,7 @@ class URLSearchParams {
519
523
}
520
524
521
525
const list = this . #searchParams;
522
- name = toUSVString ( name ) ;
526
+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
523
527
for ( let i = 0 ; i < list . length ; i += 2 ) {
524
528
if ( list [ i ] === name ) {
525
529
return list [ i + 1 ] ;
@@ -538,7 +542,7 @@ class URLSearchParams {
538
542
539
543
const list = this . #searchParams;
540
544
const values = [ ] ;
541
- name = toUSVString ( name ) ;
545
+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
542
546
for ( let i = 0 ; i < list . length ; i += 2 ) {
543
547
if ( list [ i ] === name ) {
544
548
values . push ( list [ i + 1 ] ) ;
@@ -556,10 +560,10 @@ class URLSearchParams {
556
560
}
557
561
558
562
const list = this . #searchParams;
559
- name = toUSVString ( name ) ;
563
+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
560
564
561
565
if ( value !== undefined ) {
562
- value = toUSVString ( value ) ;
566
+ value = StringPrototypeToWellFormed ( ` ${ value } ` ) ;
563
567
}
564
568
565
569
for ( let i = 0 ; i < list . length ; i += 2 ) {
@@ -582,8 +586,8 @@ class URLSearchParams {
582
586
}
583
587
584
588
const list = this . #searchParams;
585
- name = toUSVString ( name ) ;
586
- value = toUSVString ( value ) ;
589
+ name = StringPrototypeToWellFormed ( ` ${ name } ` ) ;
590
+ value = StringPrototypeToWellFormed ( ` ${ value } ` ) ;
587
591
588
592
// If there are any name-value pairs whose name is `name`, in `list`, set
589
593
// the value of the first such name-value pair to `value` and remove the
@@ -773,7 +777,7 @@ class URL {
773
777
throw new ERR_MISSING_ARGS ( 'url' ) ;
774
778
}
775
779
776
- // toUSVString is not needed.
780
+ // StringPrototypeToWellFormed is not needed.
777
781
input = `${ input } ` ;
778
782
779
783
if ( base !== undefined ) {
@@ -1006,7 +1010,7 @@ class URL {
1006
1010
}
1007
1011
1008
1012
set search ( value ) {
1009
- const href = bindingUrl . update ( this . #context. href , updateActions . kSearch , toUSVString ( value ) ) ;
1013
+ const href = bindingUrl . update ( this . #context. href , updateActions . kSearch , StringPrototypeToWellFormed ( ` ${ value } ` ) ) ;
1010
1014
if ( href ) {
1011
1015
this . #updateContext( href ) ;
1012
1016
}
@@ -1297,15 +1301,15 @@ function domainToASCII(domain) {
1297
1301
if ( arguments . length < 1 )
1298
1302
throw new ERR_MISSING_ARGS ( 'domain' ) ;
1299
1303
1300
- // toUSVString is not needed.
1304
+ // StringPrototypeToWellFormed is not needed.
1301
1305
return bindingUrl . domainToASCII ( `${ domain } ` ) ;
1302
1306
}
1303
1307
1304
1308
function domainToUnicode ( domain ) {
1305
1309
if ( arguments . length < 1 )
1306
1310
throw new ERR_MISSING_ARGS ( 'domain' ) ;
1307
1311
1308
- // toUSVString is not needed.
1312
+ // StringPrototypeToWellFormed is not needed.
1309
1313
return bindingUrl . domainToUnicode ( `${ domain } ` ) ;
1310
1314
}
1311
1315
@@ -1501,7 +1505,6 @@ function getURLOrigin(url) {
1501
1505
}
1502
1506
1503
1507
module . exports = {
1504
- toUSVString,
1505
1508
fileURLToPath,
1506
1509
pathToFileURL,
1507
1510
toPathIfFileURL,
0 commit comments