소스 검색

fix: empty duplicate alias warning on page udpate

NGPixel 2 년 전
부모
커밋
e4efb38fbd
1개의 변경된 파일8개의 추가작업 그리고 7개의 파일을 삭제
  1. 8 7
      server/models/pages.mjs

+ 8 - 7
server/models/pages.mjs

@@ -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')
-      }
-      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')
+        }
       }
       }
     }
     }