User-agent parser
Read the browser, operating system, engine and device type from a user-agent string.
How it works
Browsers describe themselves in the User-Agent header. The order and wording are messy, so each browser is matched by its own pattern.
Questions
Why does Chrome say Safari?
For compatibility, most browsers include other browsers’ names. The specific tokens tell them apart.
Is this reliable?
It’s good for analytics, not for security decisions: any client can send any user-agent.