From e725633328ac2ccce819a986e4a3795d1c3fca9a Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Thu, 20 Nov 2014 07:15:18 +0700 Subject: [PATCH] Fix #24 #80 --- src/ua-parser.js | 11 +++++++---- test/device-test.json | 10 ++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/ua-parser.js b/src/ua-parser.js index 1e776e3..8dbf650 100644 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -55,6 +55,8 @@ has : function (str1, str2) { if (typeof str1 === "string") { return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1; + } else { + return false; } }, lowerize : function (str) { @@ -513,10 +515,10 @@ ], [[MODEL, /\./g, ' '], [VENDOR, 'Microsoft'], [TYPE, MOBILE]], [ // Motorola - /\s((milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?(:?\s4g)?))[\w\s]+build\//i, - /(mot)[\s-]?(\w+)*/i, - /XT\d{3,4} build\//i - ], [[VENDOR, 'Motorola'], MODEL, [TYPE, MOBILE]], [ + /\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?(:?\s4g)?)[\w\s]+build\//i, + /mot[\s-]?(\w+)*/i, + /(XT\d{3,4}) build\//i + ], [MODEL, [VENDOR, 'Motorola'], [TYPE, MOBILE]], [ /android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i ], [MODEL, [VENDOR, 'Motorola'], [TYPE, TABLET]], [ @@ -696,6 +698,7 @@ return this; }; this.setUA(ua); + return this; }; UAParser.VERSION = LIBVERSION; diff --git a/test/device-test.json b/test/device-test.json index 67b2c7c..e32d587 100644 --- a/test/device-test.json +++ b/test/device-test.json @@ -59,6 +59,16 @@ "type" : "mobile" } }, + { + "desc" : "Moto X", + "ua" : "Mozilla/5.0 (Linux; U; Android 4.2; xx-xx; XT1058 Build/13.9.0Q2.X-70-GHOST-ATT_LE-2) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30", + "expect" : + { + "vendor" : "Motorola", + "model" : "XT1058", + "type" : "mobile" + } + }, { "desc" : "Nokia3xx", "ua" : "Nokia303/14.87 CLDC-1.1",