Permalink
Browse files

count xhr requests as bots closes #252

  • Loading branch information...
chrisbutler committed Aug 22, 2018
1 parent e1009a7 commit 4559ee5b122691ff7bf386bdff838e4ca3f64340
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/parse/url.js
View
@@ -20,14 +20,15 @@ const isValidUrl = ({ url }) => {
)
}
export const isBotFromUserAgent = ({ req }) => {
export const isBotFromUserAgent = ({ req: { xhr, ...req } }) => {
const isBot =
_.get(req, 'useragent.isAuthoritative', false) &&
_.get(req, 'useragent.browser', 'unknown') === 'unknown' ||
_.get(req, 'useragent.isBot', false)
return isBot && isBot !== 'curl' // allow @philip to create promises via curl
return xhr || // don't create promises from ajax requests (like discourse)
isBot && isBot !== 'curl' // allow @philip to create promises via curl
}
export default isValidUrl

0 comments on commit 4559ee5

Please sign in to comment.