Skip to content

Commit bd425b8

Browse files
committed
Merge pull request #240 from syranide/socketiopath
Allow changing socket.io-path via query string
2 parents 7226129 + 0d0c473 commit bd425b8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

client/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1+
var url = require('url');
12
var io = require("socket.io-client");
23
var stripAnsi = require('strip-ansi');
34
var scriptElements = document.getElementsByTagName("script");
4-
io = io.connect(typeof __resourceQuery === "string" && __resourceQuery ?
5+
6+
var urlParts = url.parse(typeof __resourceQuery === "string" && __resourceQuery ?
57
__resourceQuery.substr(1) :
68
scriptElements[scriptElements.length-1].getAttribute("src").replace(/\/[^\/]+$/, "")
79
);
810

11+
io = io.connect(
12+
url.format({
13+
protocol: urlParts.protocol,
14+
auth: urlParts.auth,
15+
host: urlParts.host
16+
}), {
17+
path: urlParts.path === '/' ? null : urlParts.path
18+
}
19+
);
20+
921
var hot = false;
1022
var initial = true;
1123
var currentHash = "";

0 commit comments

Comments
 (0)