Fixed invalid filename error during settings restore

refs https://github.com/TryGhost/Toolbox/issues/151
refs cbec6aa49e

- The error was happening due to incorrect "this" context. Because the filename and extension are only used once in this class and only for the purposes of the error message have moved the whole thing into the error message itself. No need to keep additional variables around when there's no clear usecase.
This commit is contained in:
Naz 2021-12-01 15:47:03 +04:00
parent 18b8eddd0d
commit e6503e5148

View File

@ -9,7 +9,7 @@ const tpl = require('@tryghost/tpl');
const bridge = require('../../../bridge');
const messages = {
loadError: 'Could not load {filename} file.'
loadError: 'Could not load routes.yaml file.'
};
/**
@ -38,14 +38,6 @@ class RouteSettings {
* @private
*/
this.defaultRoutesSettingHash = '3d180d52c663d173a6be791ef411ed01';
/**
* @private
*/
this.filename = 'routes';
/**
* @private
*/
this.ext = 'yaml';
this.settingsLoader = settingsLoader;
this.settingsPath = settingsPath;
@ -134,7 +126,7 @@ class RouteSettings {
if (!urlService.hasFinished()) {
if (tries > 5) {
throw new errors.InternalServerError({
message: tpl(messages.loadError, {filename: `${this.filename}.${this.ext}`})
message: tpl(messages.loadError)
});
}