smali-kazmi / detect-mobile-browser

It is a very simple & small javascript lib to detect all major modern mobile browsers in both backend & frontend
72 stars 21 forks source link

False positive for Firefox on Windows #8

Open sokraflex opened 9 years ago

sokraflex commented 9 years ago

Hello there,

another strange bug seems to appear: SmartPhone.isAny() says true when opening the web page with Firefox on Windows 10 Desktop.

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0 ... matches of course the check of return this.getUserAgent().match(/Firefox/i);

I don't know how to detect the mobile Firefox, but a solution could be using a mix of platform and user agent detection like:

return this.getUserAgent().match(/Firefox/i) && navigator.platform.match(/android/i);

This would work for all phones except the FirefoxOS as Firefox is currently only deployed to android. But in cause of my lack of experience with mobile firefox I don't commit this as a pull request and I'm only suggesting it here. Also, this solution would break the Node.JS-support.

Greetings

Bennethon commented 8 years ago

I am also experiencing this.

SmartPhone.isAny() is returning true for Firefox on Window 7 for me.

Greta commented 8 years ago

Same here for Firefox on OSX El Capitan.

Anahkiasen commented 7 years ago

Same issue here on OSX 10.12, makes the library impossible to use I'm afraid :/

oyeanuj commented 7 years ago

@Anahkiasen @Greta @Bennethon did you come up with a solution for this or an alternative library?

@smali-kazmi Thoughts on what the fix might be?

simar88 commented 7 years ago

Hi everyone! After reading https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox I edited simply the function isFirefox adding a piece of code like this: SmartPhone.isFireFox = function() { return (this.getUserAgent().match(/Firefox/i) && (this.getUserAgent().toLowerCase().indexOf("mobile")>-1 || this.getUserAgent().toLowerCase().indexOf("tablet")>-1)); }; For me is working on Mac OS but i can suppose that will work well also on windows and mobile devices. Bye, Simone

Rohit-shopasky commented 7 years ago

It returns true every time on Firefox windows 7,8,10

antonio-gg-dev commented 1 year ago

I'm also experiencing the same issue on Linux Mint and macOS. Here are the exact versions and user agents:

I have also created a CodeSandBox for quick testing. Here is the link: https://codesandbox.io/s/detect-mobile-browser-t7cly9