10000 use uri.resolve() for worker · GameJs/gamejs@013ec8c · GitHub
[go: up one dir, main page]

Skip to content

Commit 013ec8c

Browse files
committed
use uri.resolve() for worker
wasn't available when I originally wrote this code so I came up with this half-broken crap instead
1 parent b2ad3e5 commit 013ec8c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/gamejs/worker.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var gamejs = require('gamejs');
2+
var uri = require('gamejs/utils/uri');
23

34
/**
45
* @fileoverview
@@ -98,10 +99,7 @@ var workerPrefix = function workerPrefix() {
9899
* @ignore
99100
**/
100101
var create = function(workerModuleId) {
101-
// FIXME depends on 'index.html'
102-
var idx = document.location.href.indexOf('index.html');
103-
var docLoc = idx > -1 ? document.location.href.substr(0, idx) : document.location.href;
104-
var moduleRoot = docLoc + window.require.getModuleRoot();
102+
var moduleRoot = uri.resolve(document.location.href, window.require.getModuleRoot());
105103
var initialScripts = [];
106104
Array.prototype.slice.apply(document.getElementsByTagName('script'), [0]).forEach(function(script) {
107105
if (script.src) {
@@ -135,7 +133,7 @@ var create = function(workerModuleId) {
135133
* GameJs modules.
136134
*
137135
* **Note:** A Worker does not have access to the browser's `document`. So
138-
* a lot of GameJs modules - everything related to drawing to the canvas -
136+
* a lot of GameJs modules - everything related to drawing to the canvas -
139137
* do not work in the Worker.
140138
*
141139
* You can use `gamejs.time.*`, `gamejs.utils.*`, `gamejs.event.*` and probably others

0 commit comments

Comments
 (0)
0