From ae5bfb38939d7bce4d05a48087d34040df0ea82f Mon Sep 17 00:00:00 2001 From: Maximilian Haupt Date: Fri, 13 Nov 2015 12:09:32 +0100 Subject: [PATCH] Fix detection of Firefox on iOS. Firefox on iOS' ua string is also matched by the "Safari < 3.0" regular expression, unfortunately. Reorder the regular expressions so that the one for FxiOS matches first. --- src/ua-parser.js | 5 +++-- test/browser-test.json | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ua-parser.js b/src/ua-parser.js index cf00131..411e080 100644 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -294,6 +294,9 @@ /FBAV\/([\w\.]+);/i // Facebook App for iOS ], [VERSION, [NAME, 'Facebook']], [ + /fxios\/([\w\.-]+)/i // Firefox for iOS + ], [VERSION, [NAME, 'Firefox']], [ + /version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari ], [VERSION, [NAME, 'Mobile Safari']], [ @@ -310,8 +313,6 @@ // Gecko based /(navigator|netscape)\/([\w\.-]+)/i // Netscape ], [[NAME, 'Netscape'], VERSION], [ - /fxios\/([\w\.-]+)/i // Firefox for iOS - ], [VERSION, [NAME, 'Firefox']], [ /(swiftfox)/i, // Swiftfox /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i, // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror diff --git a/test/browser-test.json b/test/browser-test.json index 2e4d294..5d9b425 100644 --- a/test/browser-test.json +++ b/test/browser-test.json @@ -728,5 +728,15 @@ "version" : "43.8", "major" : "43" } + }, + { + "desc" : "Firefox iOS", + "ua" : "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) FxiOS/1.1 Mobile/13B143 Safari/601.1.46", + "expect" : + { + "name" : "Firefox", + "version" : "1.1", + "major" : "1" + } } ]