Ghost/core/server/data/meta/asset_url.js
kirrg001 0ae0a0b490 🎨 change how we get and set config
refs #6982
- a replace for all config usages
- always use config.get or config.set
- this a pure replacement, no logic has changed

[ci skip]
2016-09-20 15:59:34 +01:00

35 lines
798 B
JavaScript

var config = require('../../config'),
utils = require('../../utils');
function getAssetUrl(path, isAdmin, minify) {
var output = '';
output += utils.url.getSubdir() + '/';
if (!path.match(/^favicon\.ico$/) && !path.match(/^shared/) && !path.match(/^asset/)) {
if (isAdmin) {
output += 'ghost/';
} else {
output += 'assets/';
}
}
// Get rid of any leading slash on the path
path = path.replace(/^\//, '');
// replace ".foo" with ".min.foo" in production
if (minify) {
path = path.replace(/\.([^\.]*)$/, '.min.$1');
}
output += path;
if (!path.match(/^favicon\.ico$/)) {
output = output + '?v=' + config.get('assetHash');
}
return output;
}
module.exports = getAssetUrl;