Skip to content

Commit 3d3c000

Browse files
committed
Fix socket connection for non-inlined connections
1 parent 0cc94c0 commit 3d3c000

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

client/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ var url = require('url');
22
var SockJS = require("sockjs-client");
33
var stripAnsi = require('strip-ansi');
44
var scriptElements = document.getElementsByTagName("script");
5+
var scriptHost = scriptElements[scriptElements.length-1].getAttribute("src").replace(/\/[^\/]+$/, "");
56

7+
// If this bundle is inlined, use the resource query to get the correct url.
8+
// Else, get the url from the <script> this file was called with.
69
var urlParts = url.parse(typeof __resourceQuery === "string" && __resourceQuery ?
710
__resourceQuery.substr(1) :
8-
scriptElements[scriptElements.length-1].getAttribute("src").replace(/\/[^\/]+$/, "")
11+
(scriptHost ? scriptHost : "/")
912
);
1013

1114
var sock = null;

0 commit comments

Comments
 (0)