diff --git a/test/index.html b/test/index.html
index 78ebe8452..243a97003 100644
--- a/test/index.html
+++ b/test/index.html
@@ -54,7 +54,7 @@
return;
}
var reBasename = /[\w.-]+$/,
- basePath = (location.origin + location.pathname).split(/\btest\b/).slice(0, -1).join('test'),
+ basePath = ('//' + location.hostname + location.pathname).replace(/\btest\/$/, ''),
isModularize = /modularize/.test(ui.urlParams.build),
modulePath = ui.buildPath.replace(/\.js$/, ''),
moduleMain = modulePath.match(reBasename)[0];
diff --git a/test/underscore.html b/test/underscore.html
index 0c6865349..0a3d7ff92 100644
--- a/test/underscore.html
+++ b/test/underscore.html
@@ -89,7 +89,7 @@
return;
}
var reBasename = /[\w.-]+$/,
- basePath = (location.origin + location.pathname).split(/\btest\b/).slice(0, -1).join('test'),
+ basePath = ('//' + location.hostname + location.pathname).replace(/\btest\/$/, ''),
modulePath = ui.buildPath.replace(/\.js$/, ''),
moduleMain = modulePath.match(reBasename)[0];