0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Refactored CustomRedirectsAPI constructor

refs https://github.com/TryGhost/Toolbox/issues/139

- The pattern we use accross the codebase is a single "options" object passed into a constructor instead of passing multiple parametes. Fixed the broken pattern in CustomRedirectsAPI constructor
This commit is contained in:
Naz 2021-11-25 12:43:15 +04:00 committed by naz
parent 3a9b70412a
commit fd0a0ddf47
2 changed files with 8 additions and 7 deletions

View file

@ -138,12 +138,12 @@ class CustomRedirectsAPI {
/**
* @param {object} config
* @param {string} config.basePath
*
* @param {IRedirectManager} redirectManager
* @param {IRedirectManager} config.redirectManager
*/
constructor(config, redirectManager) {
constructor({basePath, redirectManager}) {
/** @private */
this.config = config;
this.basePath = basePath;
/** @private */
this.redirectManager = redirectManager;
}
@ -187,7 +187,7 @@ class CustomRedirectsAPI {
* @returns {string}
*/
createRedirectsFilePath(ext) {
return path.join(this.config.basePath, `redirects${ext}`);
return path.join(this.basePath, `redirects${ext}`);
}
/**

View file

@ -16,8 +16,9 @@ let customRedirectsAPI;
module.exports = {
init() {
customRedirectsAPI = new CustomRedirectsAPI({
basePath: config.getContentPath('data')
}, redirectManager);
basePath: config.getContentPath('data'),
redirectManager
});
return customRedirectsAPI.init();
},