@@ -239,8 +239,10 @@ class URL{
239239constructor ( input , base ) {
240240// toUSVString is not needed.
241241input = `${ input } ` ;
242- if ( base !== undefined && ! ( base instanceof URL ) )
242+ if ( base !== undefined &&
243+ ( ! base [ searchParams ] || ! base [ searchParams ] [ searchParams ] ) ) {
243244base = new URL ( base ) ;
245+ }
244246parse ( this , input , base ) ;
245247}
246248
@@ -885,7 +887,7 @@ class URLSearchParams{
885887}
886888
887889[ util . inspect . custom ] ( recurseTimes , ctx ) {
888- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
890+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
889891throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
890892}
891893
@@ -947,7 +949,7 @@ function merge(out, start, mid, end, lBuffer, rBuffer){
947949
948950defineIDLClass ( URLSearchParams . prototype , 'URLSearchParams' , {
949951append ( name , value ) {
950- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
952+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
951953throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
952954}
953955if ( arguments . length < 2 ) {
@@ -961,7 +963,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams',{
961963} ,
962964
963965delete ( name ) {
964- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
966+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
965967throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
966968}
967969if ( arguments . length < 1 ) {
@@ -982,7 +984,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams',{
982984} ,
983985
984986get ( name ) {
985- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
987+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
986988throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
987989}
988990if ( arguments . length < 1 ) {
@@ -1000,7 +1002,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams',{
10001002} ,
10011003
10021004getAll ( name ) {
1003- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1005+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
10041006throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
10051007}
10061008if ( arguments . length < 1 ) {
@@ -1019,7 +1021,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams',{
10191021} ,
10201022
10211023has ( name ) {
1022- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1024+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
10231025throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
10241026}
10251027if ( arguments . length < 1 ) {
@@ -1037,7 +1039,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams',{
10371039} ,
10381040
10391041set ( name , value ) {
1040- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1042+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
10411043throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
10421044}
10431045if ( arguments . length < 2 ) {
@@ -1125,15 +1127,15 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams',{
11251127// Define entries here rather than [Symbol.iterator] as the function name
11261128// must be set to `entries`.
11271129entries ( ) {
1128- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1130+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
11291131throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
11301132}
11311133
11321134return createSearchParamsIterator ( this , 'key+value' ) ;
11331135} ,
11341136
11351137forEach ( callback , thisArg = undefined ) {
1136- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1138+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
11371139throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
11381140}
11391141if ( typeof callback !== 'function' ) {
@@ -1155,15 +1157,15 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams',{
11551157
11561158// https://heycam.github.io/webidl/#es-iterable
11571159keys ( ) {
1158- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1160+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
11591161throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
11601162}
11611163
11621164return createSearchParamsIterator ( this , 'key' ) ;
11631165} ,
11641166
11651167values ( ) {
1166- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1168+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
11671169throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
11681170}
11691171
@@ -1173,7 +1175,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams',{
11731175// https://heycam.github.io/webidl/#es-stringifier
11741176// https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
11751177toString ( ) {
1176- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1178+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
11771179throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
11781180}
11791181
@@ -1275,8 +1277,10 @@ defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParamsIterator',{
12751277} ) ;
12761278
12771279function originFor ( url , base ) {
1278- if ( ! ( url instanceof URL ) )
1280+ if ( url != undefined &&
1281+ ( ! url [ searchParams ] || ! url [ searchParams ] [ searchParams ] ) ) {
12791282url = new URL ( url , base ) ;
1283+ }
12801284var origin ;
12811285const protocol = url . protocol ;
12821286switch ( protocol ) {
@@ -1399,8 +1403,10 @@ function getPathFromURLPosix(url){
13991403}
14001404
14011405function getPathFromURL ( path ) {
1402- if ( ! ( path instanceof URL ) )
1406+ if ( path == undefined || ! path [ searchParams ] ||
1407+ ! path [ searchParams ] [ searchParams ] ) {
14031408return path ;
1409+ }
14041410if ( path . protocol !== 'file:' )
14051411return new TypeError ( 'Only `file:` URLs are supported' ) ;
14061412return isWindows ? getPathFromURLWin32 ( path ) : getPathFromURLPosix ( path ) ;
0 commit comments