Skip to content

Commit

Permalink
Fixes #647: Update android regex to match Firefox for Android.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mike Taylor committed Oct 9, 2013
1 parent c81da65 commit d21ce64
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_]+)/),
Expand Down
2 changes: 2 additions & 0 deletions test/detect.html
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,15 @@ <h1>Browser detection</h1>
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)
})

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)
})
Expand Down

0 comments on commit d21ce64

Please sign in to comment.