Created
May 18, 2022 12:58
-
-
Save arnoclr/715cb08f6f37be98ddb69e46fbe0aaff to your computer and use it in GitHub Desktop.
Get browser name based on user agent JS (cloudflare workers)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const agent = request.headers.get('User-Agent') || '' | |
const browser = | |
agent.includes('Firefox/') ? 'firefox' | |
: agent.includes('Edg/') ? 'edge' | |
: agent.includes('Vivaldi/') ? 'vivaldi' | |
: agent.includes('Brave') ? 'brave' | |
: agent.includes('Chrome/') ? 'chrome' | |
: agent.includes('Safari/') ? 'safari' | |
: agent.includes('OPR/') ? 'opera' | |
: 'other'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment