fix: empty duplicate alias warning on page udpate

pull/6775/head
NGPixel 2 years ago
parent 1522b26997
commit e4efb38fbd
No known key found for this signature in database
GPG Key ID: B755FB6870B30F63

@ -477,13 +477,14 @@ export class Page extends Model {
throw new Error('ERR_PAGE_ALIAS_TOO_LONG') throw new Error('ERR_PAGE_ALIAS_TOO_LONG')
} else if (!aliasRegex.test(patch.alias)) { } else if (!aliasRegex.test(patch.alias)) {
throw new Error('ERR_PAGE_INVALID_ALIAS') throw new Error('ERR_PAGE_INVALID_ALIAS')
} } else if (patch.alias.length > 0) {
const dupAliasCheck = await WIKI.db.pages.query().where({ const dupAliasCheck = await WIKI.db.pages.query().where({
siteId: ogPage.siteId, siteId: ogPage.siteId,
alias: patch.alias alias: patch.alias
}).andWhereNot('id', ogPage.id).select('id').first() }).andWhereNot('id', ogPage.id).select('id').first()
if (dupAliasCheck) { if (dupAliasCheck) {
throw new Error('ERR_PAGE_DUPLICATE_ALIAS') throw new Error('ERR_PAGE_DUPLICATE_ALIAS')
}
} }
} }

Loading…
Cancel
Save