From 84a8eedad4203f31545a8e76d2abab9b8a6f78e4 Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Tue, 26 Mar 2013 11:09:28 +0700 Subject: [PATCH] Exclude unintended char from being captured --- src/ua-parser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ua-parser.js b/src/ua-parser.js index 26aef67..c2129cf 100644 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -78,7 +78,7 @@ match = matches[++k]; q = props[p]; // check if given property is actually array - if (typeof(q) === OBJ_TYPE) { + if (typeof(q) === OBJ_TYPE && q.length > 0) { if (q.length == 2) { // assign given value, ignore regex match result[q[0]] = q[1]; @@ -306,7 +306,7 @@ /(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i, // HTC /(zte)-(\w+)*/i, // ZTE - /(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|;\ssony)[_\s-]?([\w-]+)*/i + /(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]+)*/i // Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony ], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [