mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
fix(config): cleanup absolute path config function (#8641)
refs https://github.com/TryGhost/Ghost-CLI/issues/228 - don't try to reinvent path.isAbsolute
This commit is contained in:
parent
dc25c06b31
commit
49c8277390
@ -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)));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -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: {
|
||||
|
Loading…
Reference in New Issue
Block a user