Skip to content

Commit 4ecbae6

Browse files
committed
Merge pull request #447 from svsool/bug
fix bug when src attribute not defined on last script element Merging this in favor of #394
2 parents 2c9a461 + 924bd1b commit 4ecbae6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

client/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ if (typeof __resourceQuery === "string" && __resourceQuery) {
88
} else {
99
// Else, get the url from the <script> this file was called with.
1010
var scriptElements = document.getElementsByTagName("script");
11-
var scriptHost = scriptElements[scriptElements.length-1].getAttribute("src").replace(/\/[^\/]+$/, "");
11+
var scriptHost = scriptElements[scriptElements.length-1].getAttribute("src");
12+
scriptHost = scriptHost && scriptHost.replace(/\/[^\/]+$/, "");
1213
urlParts = url.parse((scriptHost ? scriptHost : "/"), false, true);
1314
}
1415

0 commit comments

Comments
 (0)