fixed path normalization for paths relative to root

This commit is contained in:
mikedeboer 2011-08-23 14:50:57 +02:00
commit 5bfe563305

View file

@ -103,8 +103,12 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
oop.implement(this, EventEmitter);
this.$normalizePath = function(path) {
if (!path.match(/^\w+:/))
path = location.protocol + "//" + location.host + location.pathname.replace(/\/[^\/]*$/, "") + "/" + path.replace(/^\//, "");
if (!path.match(/^\w+:/)) {
path = location.protocol + "//" + location.host
// paths starting with a slash are relative to the root (host)
+ (path.charAt(0) == "/" ? "" : location.pathname.replace(/\/[^\/]*$/, ""))
+ "/" + path.replace(/^[\/]+/, "");
}
return path;
};