diff --git a/server/models/pages.mjs b/server/models/pages.mjs index e0fc8ec1..083fd575 100644 --- a/server/models/pages.mjs +++ b/server/models/pages.mjs @@ -272,8 +272,8 @@ export class Page extends Model { } // -> Check for empty content - if (!opts.content || opts.content.trim().length < 1) { - throw new WIKI.Error.PageEmptyContent() + if (!opts.content || (opts.content ?? '').trim().length < 1) { + throw new Error('ERR_PAGE_EMPTY_CONTENT') } // -> Format CSS Scripts @@ -430,7 +430,7 @@ export class Page extends Model { // -> Basic fields if ('title' in opts.patch) { - patch.title = opts.patch.title.trim() + patch.title = (opts.patch.title ?? '').trim() historyData.affectedFields.push('title') shouldUpdateSearch = true @@ -440,18 +440,18 @@ export class Page extends Model { } if ('description' in opts.patch) { - patch.description = opts.patch.description.trim() + patch.description = (opts.patch.description ?? '').trim() historyData.affectedFields.push('description') shouldUpdateSearch = true } if ('icon' in opts.patch) { - patch.icon = opts.patch.icon.trim() + patch.icon = (opts.patch.icon ?? '').trim() historyData.affectedFields.push('icon') } if ('alias' in opts.patch) { - patch.alias = opts.patch.alias.trim() + patch.alias = (opts.patch.alias ?? '').trim() historyData.affectedFields.push('alias') if (patch.alias.length > 255) {