File tree 1 file changed +8
-8
lines changed
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -151,17 +151,17 @@ export class RequestHandler {
151
151
export function request ( dispatch , url , opts ) {
152
152
return new Promise ( ( resolve ) => {
153
153
if ( typeof url === 'string' ) {
154
- opts = { url : new URL ( url ) , ... opts }
154
+ opts = { ... opts , url : new URL ( url ) }
155
155
} else if ( url instanceof URL ) {
156
- opts = { url, ...opts }
157
- } else if ( typeof url . origin === 'string' && typeof ( url . path ?? url . pathname ) === 'string' ) {
158
- opts = opts ? { ...url , ...opts } : url
156
+ opts = { ...opts , url : new URL ( url ) }
157
+ } else if ( typeof url . origin === 'string' && url . length > 0 ) {
158
+ opts = { ...opts , url }
159
+ } else {
160
+ throw new Error ( 'invalid url' )
159
161
}
160
162
161
- if ( opts == null && typeof url === 'object' && url != null ) {
162
- url . protocol ??= 'http:'
163
- opts = { protocol : 'http:' , ...url }
164
- }
163
+ opts . url . protocol ??= 'http'
164
+ opts . url . port ??= opts . url . protocol === 'https:' ? '443' : '80'
165
165
166
166
dispatch ( opts , new RequestHandler ( opts , resolve ) )
167
167
} )
You can’t perform that action at this time.
0 commit comments