Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False negative in History API support check on Windows Phone 8.1 #1471

Closed
gaearon opened this issue Dec 11, 2014 · 1 comment · Fixed by #1472
Closed

False negative in History API support check on Windows Phone 8.1 #1471

gaearon opened this issue Dec 11, 2014 · 1 comment · Fixed by #1472

Comments

@gaearon
Copy link
Contributor

gaearon commented Dec 11, 2014

Windows Phone 8.1 supports History API, but Modernizr gives a false negative.

The check in question returns false for Android 4.0 (presumably because it reports as supporting API but in fact doesn't?). However, Microsoft recently started including Android in WP user agent, leading Modernizr to believe it's an Android when in fact it's not.

Example of failing Windows Phone UA: "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; Microsoft; Virtual) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537". As you see, it contains Android 4.0.

The fix is to add additional check for Windows Phone like I do here:

   if ((ua.indexOf('Android 2.') !== -1 ||
       (ua.indexOf('Android 4.0') !== -1)) &&
       ua.indexOf('Mobile Safari') !== -1 &&
-      ua.indexOf('Chrome') === -1) {
+      ua.indexOf('Chrome') === -1 &&
+      ua.indexOf('Windows Phone') === -1) {
     return false;
   }
@alanhogan
Copy link

The dark side of the UA string wars. (Okay, it’s all dark)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants