From 5bfe563305323345cbf6d506fc42f2b318ced65a Mon Sep 17 00:00:00 2001 From: mikedeboer Date: Tue, 23 Aug 2011 14:50:57 +0200 Subject: [PATCH] fixed path normalization for paths relative to root --- lib/ace/worker/worker_client.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ace/worker/worker_client.js b/lib/ace/worker/worker_client.js index f024b274..1fba2f7e 100644 --- a/lib/ace/worker/worker_client.js +++ b/lib/ace/worker/worker_client.js @@ -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; };