Bläddra i källkod

Fix detecting bots

Pouria Ezzati 7 år sedan
förälder
incheckning
1879c5efca
1 ändrade filer med 2 tillägg och 2 borttagningar
  1. 2 2
      server/controllers/urlController.js

+ 2 - 2
server/controllers/urlController.js

@@ -92,7 +92,7 @@ exports.urlShortener = async ({ body, user }, res) => {
 
 const browsersList = ['IE', 'Firefox', 'Chrome', 'Opera', 'Safari', 'Edge'];
 const osList = ['Windows', 'Mac Os X', 'Linux', 'Chrome OS', 'Android', 'iOS'];
-const botList = ['bot', 'dataminr', 'pinterest', 'yahoo', 'facebook'];
+const botList = ['bot', 'dataminr', 'pinterest', 'yahoo', 'facebook', 'fire', 'crawl'];
 const filterInBrowser = agent => item =>
   agent.family.toLowerCase().includes(item.toLocaleLowerCase());
 const filterInOs = agent => item =>
@@ -109,7 +109,7 @@ exports.goToUrl = async (req, res, next) => {
   const location = geoip.lookup(req.realIp);
   const country = location && location.country;
   const urls = await findUrl({ id, domain });
-  const isBot = botList.some(bot => agent.family.toLocaleLowerCase().includes(bot));
+  const isBot = botList.some(bot => agent.source.toLowerCase().includes(bot));
   if (!urls && !urls.length) return next();
   const [url] = urls;
   if (url.password && !req.body.password) {