Skip to content

Commit

Permalink
fixed path normalization for paths relative to root
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedeboer committed Aug 23, 2011
1 parent 5e9f0b0 commit 5bfe563
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/ace/worker/worker_client.js
Expand Up @@ -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;
};

Expand Down

0 comments on commit 5bfe563

Please sign in to comment.