mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added guard to asset helper for missing paths
refs #10496 - currently {{asset this/is/not/a.string}} would throw a 500 error - this commit changes that to make it throw a sensible 400 + incorrect usage error
This commit is contained in:
parent
617d861ca0
commit
1404745b50
2 changed files with 11 additions and 0 deletions
|
@ -4,12 +4,20 @@
|
|||
// Returns the path to the specified asset. The ghost flag outputs the asset path for the Ghost admin
|
||||
const proxy = require('./proxy'),
|
||||
get = require('lodash/get'),
|
||||
i18n = proxy.i18n,
|
||||
errors = proxy.errors,
|
||||
getAssetUrl = proxy.metaData.getAssetUrl,
|
||||
SafeString = proxy.SafeString;
|
||||
|
||||
module.exports = function asset(path, options) {
|
||||
const hasMinFile = get(options, 'hash.hasMinFile');
|
||||
|
||||
if (!path) {
|
||||
throw new errors.IncorrectUsageError({
|
||||
message: i18n.t('warnings.helpers.asset.pathIsRequired')
|
||||
});
|
||||
}
|
||||
|
||||
return new SafeString(
|
||||
getAssetUrl(path, hasMinFile)
|
||||
);
|
||||
|
|
|
@ -519,6 +519,9 @@
|
|||
"flagMustBeEnabled": "The {flagName} flag must be enabled in labs if you wish to use the \\{\\{{helperName}\\}\\} helper.",
|
||||
"seeLink": "See {url}",
|
||||
"mustBeCalledAsBlock": "The \\{\\{{helperName}\\}\\} helper must be called as a block. E.g. \\{\\{#{helperName}\\}\\} \\{\\{/{helperName}\\}\\}",
|
||||
"asset": {
|
||||
"pathIsRequired": "The \\{\\{asset\\}\\} helper must be passed a path"
|
||||
},
|
||||
"foreach": {
|
||||
"iteratorNeeded": "Need to pass an iterator to #foreach"
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue