File tree Expand file tree Collapse file tree 4 files changed +10
-50
lines changed Expand file tree Collapse file tree 4 files changed +10
-50
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ export abstract class Transport extends Emitter<
172
172
*/
173
173
public pause ( onPause : ( ) => void ) { }
174
174
175
- protected uri ( schema : string , query : Record < string , unknown > = { } ) {
175
+ protected createUri ( schema : string , query : Record < string , unknown > = { } ) {
176
176
return (
177
177
schema +
178
178
"://" +
@@ -191,8 +191,8 @@ export abstract class Transport extends Emitter<
191
191
private _port ( ) {
192
192
if (
193
193
this . opts . port &&
194
- ( ( this . opts . secure && this . opts . port !== " 443" ) ||
195
- ( ! this . opts . secure && this . opts . port !== "80" ) )
194
+ ( ( this . opts . secure && Number ( this . opts . port !== 443 ) ) ||
195
+ ( ! this . opts . secure && Number ( this . opts . port ) !== 80 ) )
196
196
) {
197
197
return ":" + this . opts . port ;
198
198
} else {
Original file line number Diff line number Diff line change @@ -215,10 +215,9 @@ export class Polling extends Transport {
215
215
*
216
216
* @private
217
217
*/
218
- uri ( ) {
219
- let query : { b64 ?: number ; sid ?: string } = this . query || { } ;
218
+ private uri ( ) {
220
219
const schema = this . opts . secure ? "https" : "http" ;
221
- let port = "" ;
220
+ const query : { b64 ?: number ; sid ?: string } = this . query || { } ;
222
221
223
222
// cache busting is forced
224
223
if ( false !== this . opts . timestampRequests ) {
@@ -229,26 +228,7 @@ export class Polling extends Transport {
229
228
query . b64 = 1 ;
230
229
}
231
230
232
- // avoid port if default for schema
233
- if (
234
- this . opts . port &&
235
- ( ( "https" === schema && Number ( this . opts . port ) !== 443 ) ||
236
- ( "http" === schema && Number ( this . opts . port ) !== 80 ) )
237
- ) {
238
- port = ":" + this . opts . port ;
239
- }
240
-
241
- const encodedQuery = encode ( query ) ;
242
- const ipv6 = this . opts . hostname . indexOf ( ":" ) !== - 1 ;
243
-
244
- return (
245
- schema +
246
- "://" +
247
- ( ipv6 ? "[" + this . opts . hostname + "]" : this . opts . hostname ) +
248
- port +
249
- this . opts . path +
250
- ( encodedQuery . length ? "?" + encodedQuery : "" )
251
- ) ;
231
+ return this . createUri ( schema , query ) ;
252
232
}
253
233
254
234
/**
Original file line number Diff line number Diff line change @@ -175,19 +175,9 @@ export class WS extends Transport {
175
175
*
176
176
* @private
177
177
*/
178
- uri ( ) {
179
- let query : { b64 ?: number } = this . query || { } ;
178
+ private uri ( ) {
180
179
const schema = this . opts . secure ? "wss" : "ws" ;
181
- let port = "" ;
182
-
183
- // avoid port if default for schema
184
- if (
185
- this . opts . port &&
186
- ( ( "wss" === schema && Number ( this . opts . port ) !== 443 ) ||
187
- ( "ws" === schema && Number ( this . opts . port ) !== 80 ) )
188
- ) {
189
- port = ":" + this . opts . port ;
190
- }
180
+ const query : { b64 ?: number } = this . query || { } ;
191
181
192
182
// append timestamp to URI
193
183
if ( this . opts . timestampRequests ) {
@@ -199,17 +189,7 @@ export class WS extends Transport {
199
189
query . b64 = 1 ;
200
190
}
201
191
202
- const encodedQuery = encode ( query ) ;
203
- const ipv6 = this . opts . hostname . indexOf ( ":" ) !== - 1 ;
204
-
205
- return (
206
- schema +
207
- "://" +
208
- ( ipv6 ? "[" + this . opts . hostname + "]" : this . opts . hostname ) +
209
- port +
210
- this . opts . path +
211
- ( encodedQuery . length ? "?" + encodedQuery : "" )
212
- ) ;
192
+ return this . createUri ( schema , query ) ;
213
193
}
214
194
215
195
/**
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ export class WT extends Transport {
35
35
}
36
36
// @ts -ignore
37
37
this . transport = new WebTransport (
38
- this . uri ( "https" ) ,
38
+ this . createUri ( "https" ) ,
39
39
this . opts . transportOptions [ this . name ]
40
40
) ;
41
41
You can’t perform that action at this time.
0 commit comments