From d21ce64170873d3c691fbfad9ac7c698de887fdb Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Wed, 9 Oct 2013 16:27:32 -0500 Subject: [PATCH] Fixes #647: Update android regex to match Firefox for Android. Firefox for Android doesn't include Android version information in the UA string. This change allows the regex to detect Firefox for Android as an Android browser with the caveat that os.version will be undefined. But this can still be useful when trying to distinguish between ios and android, for example. --- src/detect.js | 2 +- test/detect.html | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/detect.js b/src/detect.js index c7a8c06ef..3df3030e2 100644 --- a/src/detect.js +++ b/src/detect.js @@ -6,7 +6,7 @@ function detect(ua){ var os = this.os = {}, browser = this.browser = {}, webkit = ua.match(/WebKit\/([\d.]+)/), - android = ua.match(/(Android)\s+([\d.]+)/), + android = ua.match(/(Android);?\s+([\d.]+)?/), ipad = ua.match(/(iPad).*OS\s([\d_]+)/), ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/), iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/), diff --git a/test/detect.html b/test/detect.html index ab79956a2..a9dc43b6e 100644 --- a/test/detect.html +++ b/test/detect.html @@ -337,6 +337,7 @@

Browser detection

detect(UA.Firefox_13_Tablet, function(os, browser){ t.assertTrue(browser.firefox) t.assertFalse(browser.webkit) + t.assertTrue(os.android) t.assertFalse(os.phone) t.assertTrue(os.tablet) }) @@ -344,6 +345,7 @@

Browser detection

detect(UA.Firefox_13_Phone, function(os, browser){ t.assertTrue(browser.firefox) t.assertFalse(browser.webkit) + t.assertTrue(os.android) t.assertTrue(os.phone) t.assertFalse(os.tablet) })