diff --git a/server/helpers/page.js b/server/helpers/page.js index 65837b16..24d8d935 100644 --- a/server/helpers/page.js +++ b/server/helpers/page.js @@ -89,5 +89,18 @@ module.exports = { } else { return false } + }, + /** + * Get file extension from content type + */ + getFileExtension(contentType) { + switch (contentType) { + case 'markdown': + return 'md' + case 'html': + return 'html' + default: + return 'txt' + } } } diff --git a/server/models/pages.js b/server/models/pages.js index f39cd94f..6d538838 100644 --- a/server/models/pages.js +++ b/server/models/pages.js @@ -159,14 +159,7 @@ module.exports = class Page extends Model { * @returns {string} File Extension */ getFileExtension() { - switch (this.contentType) { - case 'markdown': - return 'md' - case 'html': - return 'html' - default: - return 'txt' - } + return pageHelper.getFileExtension(this.contentType) } /** diff --git a/server/modules/storage/git/storage.js b/server/modules/storage/git/storage.js index 9e3d44a3..d175fdbf 100644 --- a/server/modules/storage/git/storage.js +++ b/server/modules/storage/git/storage.js @@ -349,7 +349,7 @@ module.exports = { new stream.Transform({ objectMode: true, transform: async (page, enc, cb) => { - let fileName = `${page.path}.${page.getFileExtension()}` + let fileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}` if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) { fileName = `${page.localeCode}/${fileName}` }