Просмотр исходного кода

fix: error when domain is undefined

poeti8 5 лет назад
Родитель
Сommit
506c43dfcd
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      server/handlers/links.ts

+ 2 - 2
server/handlers/links.ts

@@ -115,7 +115,7 @@ export const edit: Handler = async (req, res) => {
   }
 
   const targetDomain = URL.parse(target).hostname;
-  const domain_id = link.domain_id;
+  const domain_id = link.domain_id || null;
 
   const queries = await Promise.all([
     validators.cooldown(req.user),
@@ -265,7 +265,7 @@ export const redirect = (app: ReturnType<typeof next>): Handler => async (
   const address = req.params.id.replace("+", "");
   const link = await query.link.find({
     address,
-    domain_id: domain && domain.id
+    domain_id: domain ? domain.id : null
   });
 
   // 3. When no link, if has domain redirect to domain's homepage