Skip to content

Commit

Permalink
Fix socket connection for non-inlined connections
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceK33z committed Nov 27, 2015
1 parent 0cc94c0 commit 3d3c000
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ var url = require('url');
var SockJS = require("sockjs-client");
var stripAnsi = require('strip-ansi');
var scriptElements = document.getElementsByTagName("script");
var scriptHost = scriptElements[scriptElements.length-1].getAttribute("src").replace(/\/[^\/]+$/, "");

This comment has been minimized.

Copy link
@STRML

STRML Jan 13, 2016

This is causing some problems in our build; you can't really assume that the webpack socket script is the last script on the page.


// If this bundle is inlined, use the resource query to get the correct url.
// Else, get the url from the <script> this file was called with.

This comment has been minimized.

Copy link
@STRML

STRML Jan 13, 2016

You can't reliably do this, since the script may have a defer or async attribute. The bundle itself is going to have to to be built to contain this url somehow.

This comment has been minimized.

Copy link
@SpaceK33z

SpaceK33z Jan 13, 2016

Author Member

Could you make a PR with the fix? I don't have time for this soon. Or please create an issue for this, otherwise it'll get buried.

This comment has been minimized.

Copy link
@Zache
var urlParts = url.parse(typeof __resourceQuery === "string" && __resourceQuery ?
__resourceQuery.substr(1) :
scriptElements[scriptElements.length-1].getAttribute("src").replace(/\/[^\/]+$/, "")
(scriptHost ? scriptHost : "/")
);

var sock = null;
Expand Down

0 comments on commit 3d3c000

Please sign in to comment.