Skip to content

Commit dc10d06

Browse files
jkrehmevilebottnawi
authored andcommittedDec 9, 2019
feat(client): allow sock port to use location's port (#2341)
1 parent a599f99 commit dc10d06

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
 

‎client-src/default/utils/createSocketUrl.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ function getSocketUrl(urlParts, loc) {
7676
// they are not provided
7777
const sockHost = query.sockHost || hostname;
7878
const sockPath = query.sockPath || '/sockjs-node';
79-
const sockPort = query.sockPort || port;
79+
let sockPort = query.sockPort || port;
80+
81+
if (sockPort === 'location') {
82+
sockPort = loc.port;
83+
}
8084

8185
return url.format({
8286
protocol,

‎test/client/utils/createSocketUrl.test.js

+10
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ describe('createSocketUrl', () => {
141141
'http://localhost',
142142
'http://localhost:8097/sockjs-node',
143143
],
144+
[
145+
'?http://example.com:8096&sockPort=location',
146+
'http://something.com',
147+
'http://example.com/sockjs-node',
148+
],
149+
[
150+
'?http://0.0.0.0:8096&sockPort=location',
151+
'http://localhost:3000',
152+
'http://localhost:3000/sockjs-node',
153+
],
144154
];
145155
samples3.forEach(([scriptSrc, loc, expected]) => {
146156
test(`should return socket ${expected} for query ${scriptSrc} and location ${loc}`, () => {

0 commit comments

Comments
 (0)
Please sign in to comment.