From 49c827739096e7d4e860945cd728ff36c27daed4 Mon Sep 17 00:00:00 2001 From: Austin Burdine Date: Wed, 5 Jul 2017 18:04:18 -0400 Subject: [PATCH] fix(config): cleanup absolute path config function (#8641) refs https://github.com/TryGhost/Ghost-CLI/issues/228 - don't try to reinvent path.isAbsolute --- core/server/config/utils.js | 13 ++++++------- core/test/unit/config/utils_spec.js | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/server/config/utils.js b/core/server/config/utils.js index 8c4058e311..aa177dd095 100644 --- a/core/server/config/utils.js +++ b/core/server/config/utils.js @@ -34,13 +34,12 @@ exports.makePathsAbsolute = function makePathsAbsolute(obj, parent) { _.each(obj, function (configValue, pathsKey) { if (_.isObject(configValue)) { makePathsAbsolute.bind(self)(configValue, parent + ':' + pathsKey); - } else { - if (_.isString(configValue) && - (configValue.match(/\/+|\\+/) || configValue === '.') && - (configValue[0] !== '/' && configValue[0] !== '\\') - ) { - self.set(parent + ':' + pathsKey, path.join(__dirname + '/../../../', configValue)); - } + } else if ( + _.isString(configValue) && + (configValue.match(/\/+|\\+/) || configValue === '.') && + !path.isAbsolute(configValue) + ) { + self.set(parent + ':' + pathsKey, path.normalize(path.join(__dirname, '../../..', configValue))); } }); }; diff --git a/core/test/unit/config/utils_spec.js b/core/test/unit/config/utils_spec.js index df1769aeda..7cb7fba4ee 100644 --- a/core/test/unit/config/utils_spec.js +++ b/core/test/unit/config/utils_spec.js @@ -41,7 +41,7 @@ describe('UNIT: Config utils', function () { changedKey.length.should.eql(0); }); - it('ensure we don\' change absolute paths', function () { + it('ensure we don\'t change absolute paths', function () { var changedKey = [], obj = { database: {