From e4efb38fbd6a663a8713a583025806c9056ca80d Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sun, 28 May 2023 03:17:38 +0000 Subject: [PATCH] fix: empty duplicate alias warning on page udpate --- server/models/pages.mjs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/models/pages.mjs b/server/models/pages.mjs index e8a05cd1..c24a8cdc 100644 --- a/server/models/pages.mjs +++ b/server/models/pages.mjs @@ -477,13 +477,14 @@ export class Page extends Model { throw new Error('ERR_PAGE_ALIAS_TOO_LONG') } else if (!aliasRegex.test(patch.alias)) { throw new Error('ERR_PAGE_INVALID_ALIAS') - } - const dupAliasCheck = await WIKI.db.pages.query().where({ - siteId: ogPage.siteId, - alias: patch.alias - }).andWhereNot('id', ogPage.id).select('id').first() - if (dupAliasCheck) { - throw new Error('ERR_PAGE_DUPLICATE_ALIAS') + } else if (patch.alias.length > 0) { + const dupAliasCheck = await WIKI.db.pages.query().where({ + siteId: ogPage.siteId, + alias: patch.alias + }).andWhereNot('id', ogPage.id).select('id').first() + if (dupAliasCheck) { + throw new Error('ERR_PAGE_DUPLICATE_ALIAS') + } } }