Pārlūkot izejas kodu

Fix redirecting to wrong target. Closes #65

Pouria Ezzati 7 gadi atpakaļ
vecāks
revīzija
8892cba7e4
1 mainītis faili ar 1 papildinājumiem un 1 dzēšanām
  1. 1 1
      server/controllers/urlController.js

+ 1 - 1
server/controllers/urlController.js

@@ -101,7 +101,7 @@ exports.goToUrl = async (req, res, next) => {
   const isBot =
     botList.some(bot => agent.source.toLowerCase().includes(bot)) || agent.family === 'Other';
   if (!urls && !urls.length) return next();
-  const [url] = urls;
+  const url = urls.find(item => (domain ? item.domain === domain : !item.domain));
   if (url.password && !req.body.password) {
     req.protectedUrl = id;
     return next();