JayBizzle/Crawler-Detect

If User-Agent is empty?

orukaz opened this issue · 2 comments

What to do if the "User-Agent" is empty, for example (IP: 217.146.69.36)

IP User-Agent Bot name Is bot?
84.50.25.234 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36 false
217.146.69.36 false

Whether empty User-Agents can be treated as robots? Or it's better not list these as a robot and it is better to make additional empty user-agent IF clause to my webpage code?

I think if the user agent is empty, we can make no assumptions as to whether this is a bot or not, so using an extra if statement to do as you see fit would be the way to go here

I think if the user agent is empty, we can make no assumptions as to whether this is a bot or not, so using an extra if statement to do as you see fit would be the way to go here

If user agent is empty, this is almost certainly a bot, since there are no browsers which sends empty user agent. It may be spoofed, but it will not be empty. While adding extra check before isCrawler() is not a big deal, it is also surprising (since it is not documented and example in README is unreliable) and counterproductive (isCrawler() looks incomplete, since it always needs extra check for this one case).