File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ module.exports = async (ctx, next) => {
21
21
if ( ! serverUrl . startsWith ( 'http' ) ) {
22
22
serverUrl = `http://${ serverUrl } ` ;
23
23
}
24
- if ( ! socketUrl . startsWith ( 'ws:// ' ) ) {
24
+ if ( ! socketUrl . startsWith ( 'ws' ) ) {
25
25
socketUrl = `ws://${ socketUrl } ` ;
26
26
}
27
27
Original file line number Diff line number Diff line change @@ -14,15 +14,15 @@ let reopenCount = 0;
14
14
15
15
class SockClient extends EventEmitter {
16
16
static composeEndpoint = ( socketUrl , accessToken = '' ) => {
17
- const re = / ( \w + ?: \/ \/ ) ? ( [ ^ \\ ? ] + ) / ;
17
+ const re = / w s s ? : \/ \/ ( [ ^ \\ ? ] + ) / ;
18
18
const suffix = `?sid=${ accessToken } ` ;
19
19
const matchParts = `${ socketUrl } ` . match ( re ) ;
20
- let wsPrefix = 'ws://' ;
21
- if ( typeof window === 'object' && window . location . protocol === 'https:' ) {
22
- wsPrefix = 'wss://' ;
20
+
21
+ if ( ! matchParts ) {
22
+ throw Error ( `Invalid socket url: ${ socketUrl } ` ) ;
23
23
}
24
24
25
- return `${ wsPrefix } ${ matchParts [ 2 ] } ${ suffix } ` ;
25
+ return `${ matchParts [ 0 ] } ${ suffix } ` ;
26
26
} ;
27
27
28
28
constructor ( endpoint , options = { } ) {
You can’t perform that action at this time.
0 commit comments