mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-04 17:04:59 +03:00
0b2940d587
refs #6982 - do not add the subdir property as static config value - create functions to read subdir and protected slugs on runtime
35 lines
791 B
JavaScript
35 lines
791 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.assetHash;
|
|
}
|
|
|
|
return output;
|
|
}
|
|
|
|
module.exports = getAssetUrl;
|