Last active
August 13, 2019 21:39
-
-
Save ignaciolg/c63003460cfecec2137c57e10169ba3a to your computer and use it in GitHub Desktop.
Check from the server side the user agent of the client and determine what browser is
This file contains 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
// only google chrome | |
const isChrome = (userAgent) => /^.(?!.*samsungbrowser).*chrome(?!.*opr|.*edg|.*Puffin|.*SamsungBrowser|.*YaBrowser|.*miui).*$/i.test(userAgent) | |
// only safari browser | |
const isSafari = (userAgent) => /^((?!chrome|android|opios|fxios).)*safari/i.test(userAgent); | |
// only edge based on chrome | |
const isEdge = (userAgent) =>/^.*edge?\//i.test(userAgent); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment