biggora / express-useragent

NodeJS user-agent middleware
http://www.gordejev.lv
MIT License
645 stars 113 forks source link

isBot returns non boolean value 'google' #138

Open Grant-Lay opened 4 years ago

Grant-Lay commented 4 years ago

isBot returns false when the user agent is not a bot but returns 'google' when using the google bot user agent. Should it not display true instead and then have a separate property botType which returns google?

guyius commented 3 years ago

I think this is actually affecting all known bots, https://github.com/biggora/express-useragent/blob/master/lib/express-useragent.js#L806 the function returns the second item in the array from regex exec function which is either a string or null. I can see postman also returns a string for example.

mehmet-yilmaz commented 3 years ago

Workaround: Use string type in the application and cast the result to the string by request.useragent.isBot.toString() This works fine in my typescript project.