fix: null-safe trim on all page fields to prevent save crash

pull/7973/head
Gabriel Mowses (Mouse) 1 week ago
parent b034f5d191
commit 78b112ad3c

@ -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) {

Loading…
Cancel
Save