diff --git a/src/node.js b/src/node.js index 76dd8a6a22..9e7a2532b1 100644 --- a/src/node.js +++ b/src/node.js @@ -667,13 +667,17 @@ var posix = posixModule.exports; var pathModule = createInternalModule("path", function (exports) { exports.join = function () { - var joined = ""; + var joined = "", + dotre = /^\.\//g, + dotreplace = "", + dotdotre = /(^|(\/)([^\/]+\/)?)\.\.\//g, + dotdotreplace = "" for (var i = 0; i < arguments.length; i++) { var part = arguments[i].toString(); /* Some logic to shorten paths */ if (part === ".") continue; - while (/^\.\//.exec(part)) part = part.replace(/^\.\//, ""); + while (dotre.exec(part)) part.replace(dotre, dotreplace); if (i === 0) { part = part.replace(/\/*$/, "/"); @@ -684,7 +688,10 @@ var pathModule = createInternalModule("path", function (exports) { } joined += part; } + // replace /foo/../bar/baz with /bar/baz + while (dotdotre.exec(joined)) joined.replace(dotdotre, dotdotreplace); return joined; + }; exports.dirname = function (path) { @@ -839,6 +846,8 @@ Module.prototype.loadObject = function (filename, loadPromise) { function cat (id, loadPromise) { var promise; + + debug(id); if (id.match(/^http:\/\//)) { promise = new process.Promise();