From 60c522a69635a0d3dfa99226c661c869ad8535dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Cruz?= Date: Fri, 4 Oct 2013 12:38:08 +0100 Subject: [PATCH] Fix absolute paths ending with / not going through the FsResolver, fixes #898. --- lib/core/resolverFactory.js | 2 +- test/core/resolverFactory.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/core/resolverFactory.js b/lib/core/resolverFactory.js index 6add1304..f2568951 100644 --- a/lib/core/resolverFactory.js +++ b/lib/core/resolverFactory.js @@ -60,7 +60,7 @@ function getConstructor(source, config, registryClient) { // If source is ./ or ../ or an absolute path absolutePath = path.resolve(config.cwd, source); - if (/^\.\.?[\/\\]/.test(source) || /^~\//.test(source) || path.normalize(source) === absolutePath) { + if (/^\.\.?[\/\\]/.test(source) || /^~\//.test(source) || path.normalize(source).replace(/[\/\\]+$/, '') === absolutePath) { promise = Q.nfcall(fs.stat, path.join(absolutePath, '.git')) .then(function (stats) { if (stats.isDirectory()) { diff --git a/test/core/resolverFactory.js b/test/core/resolverFactory.js index 54d05589..0f953fc3 100644 --- a/test/core/resolverFactory.js +++ b/test/core/resolverFactory.js @@ -303,6 +303,11 @@ describe('resolverFactory', function () { temp = path.resolve(__dirname, '../assets/package-a'); endpoints[temp] = temp; + // Absolute path that ends with a / + // See: https://github.com/bower/bower/issues/898 + temp = path.resolve(__dirname, '../assets/package-a') + '/'; + endpoints[temp] = temp; + // Relative path endpoints[__dirname + '/../assets/package-a'] = temp;