File tree Expand file tree Collapse file tree 4 files changed +14
-15
lines changed Expand file tree Collapse file tree 4 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -25,13 +25,12 @@ const defaultOptions = {
25
25
useErrorOverlay : false ,
26
26
useProgress : false ,
27
27
} ;
28
- const parsedResourceQuery = parseURL ( ) ;
29
-
30
- let options = defaultOptions ;
28
+ const parsedResourceQuery = parseURL ( __resourceQuery ) ;
29
+ const options = defaultOptions ;
31
30
32
31
// Handle Node.js legacy format and `new URL()`
33
32
if ( parsedResourceQuery . query ) {
34
- options = Object . assign ( options , parsedResourceQuery . query ) ;
33
+ Object . assign ( options , parsedResourceQuery . query ) ;
35
34
} else if ( parsedResourceQuery . searchParams ) {
36
35
const paramsToObject = ( entries ) => {
37
36
const result = { } ;
@@ -43,7 +42,7 @@ if (parsedResourceQuery.query) {
43
42
return result ;
44
43
} ;
45
44
46
- options = Object . assign (
45
+ Object . assign (
47
46
options ,
48
47
paramsToObject ( parsedResourceQuery . searchParams . entries ( ) )
49
48
) ;
Original file line number Diff line number Diff line change @@ -32,10 +32,6 @@ function createSocketURL(parsedURL) {
32
32
hostname = self . location . hostname ;
33
33
}
34
34
35
- if ( ! hostname && protocol === 'file:' ) {
36
- hostname = 'localhost' ;
37
- }
38
-
39
35
// `hostname` can be empty when the script path is relative. In that case, specifying a protocol would result in an invalid URL.
40
36
// When https is used in the app, secure websockets are always necessary because the browser doesn't accept non-secure websockets.
41
37
if ( hostname && isInAddrAny && self . location . protocol === 'https:' ) {
@@ -70,10 +66,11 @@ function createSocketURL(parsedURL) {
70
66
//
71
67
// All of these sock url params are optionally passed in through resourceQuery,
72
68
// so we need to fall back to the default if they are not provided
73
- const socketURLHostname = ( getURLSearchParam ( 'host' ) || hostname ) . replace (
74
- / ^ \[ ( .* ) \] $ / ,
75
- '$1'
76
- ) ;
69
+ const socketURLHostname = (
70
+ getURLSearchParam ( 'host' ) ||
71
+ hostname ||
72
+ 'localhost'
73
+ ) . replace ( / ^ \[ ( .* ) \] $ / , '$1' ) ;
77
74
78
75
if ( ! port || port === '0' ) {
79
76
port = self . location . port ;
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ describe('index', () => {
53
53
} ) ;
54
54
55
55
// createSocketUrl
56
- jest . setMock ( '../../client-src/utils/createSocketUrl .js' , ( ) => 'mock-url' ) ;
56
+ jest . setMock ( '../../client-src/utils/createSocketURL .js' , ( ) => 'mock-url' ) ;
57
57
58
58
// issue: https://github.com/jsdom/jsdom/issues/2112
59
59
delete window . location ;
Original file line number Diff line number Diff line change @@ -9,7 +9,10 @@ const BaseClient = require('../../../client/clients/BaseClient');
9
9
module . exports = class SockJSClient extends BaseClient {
10
10
constructor ( url ) {
11
11
super ( ) ;
12
- this . sock = new SockJS ( url ) ;
12
+
13
+ this . sock = new SockJS (
14
+ url . replace ( / ^ w s : / i, 'http://' ) . replace ( / ^ w s s : / i, 'https://' )
15
+ ) ;
13
16
}
14
17
15
18
static getClientPath ( options ) {
You can’t perform that action at this time.
0 commit comments