In reply to Maxime Beguin.

Well, if you look at the original tweet that started this, it shows a screenshot of some extremely cryptic-looking JavaScript code. To be honest, if I saw code that looked like that on my own site, my first thought would be, “Oh no, the site’s been hacked.” (Because hackers love to use obfuscated code.) If I were to examine it further, I would probably conclude that it doesn’t really seem like a hack, but it appears to be checking for a bunch of user agents I’ve never heard of – “ighth”, “tmetr”, “eadles”, “ingdo”, and some others that are even stranger-looking. I would probably guess that these are simply some obscure bots that the author of the code decided to exclude for some reason (perhaps they’re just badly-behaved). I would be unlikely to realize that these are actually substrings of legitimate performance testing tools – Lighthouse, GTmetrix, Headless Chrome, and Pingdom.

To answer your original question – the regular expression has the /i modifier at the end, so it is a case-insensitive match – capitalized letters can’t be the issue.

It seems to me, if the author of the code had a legitimate reason for wanting to detect, say, Lighthouse (for example), then it would be better to simply use “Lighthouse” in the regular expression match. Not only is it easier to understand, it’s also less likely to result in false positive matches (e.g., suppose in the future someone creates a browser named “Nighthawk”). I can’t see any reason why anyone would use short, cryptic substrings of the actual user agents – unless the intent was to obscure the purpose of the code.