mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 11:22:19 +03:00
264661ee09
closes #7423 - Extend our dirty theme override cache clear hack to also reset the asset hash _ This brings alpha into line with the LTS branch - This still needs a rewrite for Ghost 1.0.0 🙄
39 lines
913 B
JavaScript
39 lines
913 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$/)) {
|
|
if (!config.get('assetHash')) {
|
|
config.set('assetHash', utils.generateAssetHash());
|
|
}
|
|
|
|
output = output + '?v=' + config.get('assetHash');
|
|
}
|
|
|
|
return output;
|
|
}
|
|
|
|
module.exports = getAssetUrl;
|