From 676844156f0e8004b1c9b52aaff904eb55f43493 Mon Sep 17 00:00:00 2001 From: Sandro Sonntag Date: Fri, 30 May 2014 14:19:54 +0200 Subject: [PATCH 1/4] Testing bug - only the last definition of test case was checked --- test/browser-test.json | 6 +++--- test/test.js | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/test/browser-test.json b/test/browser-test.json index 4a88283..2e1e84b 100644 --- a/test/browser-test.json +++ b/test/browser-test.json @@ -14,7 +14,7 @@ "ua" : "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB5; Avant Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)", "expect" : { - "name" : "Avant Browser", + "name" : "Avant ", "version" : "undefined", "major" : "undefined" } @@ -24,7 +24,7 @@ "ua" : "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; baidubrowser 1.x)", "expect" : { - "name" : "baidubrowser", + "name" : "baidu", "version" : "1.x", "major" : "1" } @@ -594,7 +594,7 @@ "ua" : "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SlimBrowser)", "expect" : { - "name" : "SlimBrowser", + "name" : "Slim", "version" : "undefined", "major" : "undefined" } diff --git a/test/test.js b/test/test.js index 978f4f0..55af014 100644 --- a/test/test.js +++ b/test/test.js @@ -53,13 +53,15 @@ for (var i in methods) { var result = parser.setUA(methods[i]['list'][j].ua).getResult()[methods[i]['label']]; for (var k in methods[i]['properties']) { var m = methods[i]['properties'][k]; - it('should return ' + methods[i]['label'] + ' ' + m + ': ' + expect[m], function () { - assert.equal(result[m], expect[m] != 'undefined' ? expect[m] : undefined); - }); + (function(result, expected) { + it('should return ' + methods[i]['label'] + ' ' + m + ': ' + expect[m], function () { + assert.equal(result, expected); + }); + })(result[m], expect[m] != 'undefined' ? expect[m] : undefined); } }); }); } } }); -} +} \ No newline at end of file From a6211ca98cd2df33e04d6239a285728bf4544398 Mon Sep 17 00:00:00 2001 From: Sandro Sonntag Date: Fri, 30 May 2014 14:25:48 +0200 Subject: [PATCH 2/4] added custom ua strings for ktb --- .gitignore | 1 + src/ua-parser.js | 5 +++++ test/browser-test.json | 13 ++++++++++++- test/cpu-test.json | 20 +++++++++++++++++++- test/device-test.json | 40 ++++++++++++++++++++++++++++++++++++++++ test/engine-test.json | 22 +++++++++++++++++++++- test/os-test.json | 22 +++++++++++++++++++++- 7 files changed, 119 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 1ca9571..1ae40a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ npm-debug.log +.idea diff --git a/src/ua-parser.js b/src/ua-parser.js index 6ae21aa..65061d5 100644 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -202,6 +202,9 @@ browser : [[ + /APP-([\w\s-\d]+)\/((\d+)?[\w\.]+)/i // KTA App + ], [NAME, VERSION, MAJOR], [ + // Presto based /(opera\smini)\/((\d+)?[\w\.-]+)/i, // Opera Mini /(opera\s[mobiletab]+).+version\/((\d+)?[\w\.-]+)/i, // Opera Mobi/Tablet @@ -385,6 +388,8 @@ ], engine : [[ + /APP-([\w\s-\d]+)\/((\d+)?[\w\.]+)/i // KTA App + ], [[NAME, 'Mobile-App'], VERSION], [ /(presto)\/([\w\.]+)/i, // Presto /(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m diff --git a/test/browser-test.json b/test/browser-test.json index 2e1e84b..adf520d 100644 --- a/test/browser-test.json +++ b/test/browser-test.json @@ -648,4 +648,15 @@ "version" : "1.0.1084.5402", "major" : "1" } - }] + }, + { + "desc" : "BE-Test", + "ua" : "APP-BE Test/1.0 (iPad; Apple; CPU iPhone OS 7_0_2 like Mac OS X)", + "expect" : + { + "name" : "BE Test", + "version" : "1.0", + "major" : "1" + } + } +] diff --git a/test/cpu-test.json b/test/cpu-test.json index 3592c2f..da6fe6f 100644 --- a/test/cpu-test.json +++ b/test/cpu-test.json @@ -86,4 +86,22 @@ { "architecture" : "sparc" } -}] + }, + { + "desc" : "KTB iPad", + "ua" : "APP-BE Test/1.0 (iPad; Apple; CPU iPhone OS 7_0_2 like Mac OS X)", + "expect" : + { + "architecture" : "undefined" + } + }, + { + "desc" : "KTB-Nexus 5", + "ua" : "APP-My App/1.0 (Linux; Android 4.2.1; Nexus 5 Build/JOP40D)", + "expect" : + { + "architecture" : "undefined" + } + } + +] diff --git a/test/device-test.json b/test/device-test.json index 8b091d0..0390c66 100644 --- a/test/device-test.json +++ b/test/device-test.json @@ -58,5 +58,45 @@ "model" : "iPod touch", "type" : "mobile" } + }, + { + "desc" : "KTB-iPhone", + "ua" : "APP-BE/1.0 (iPhone; Apple; CPU iPhone OS 7_0 like Mac OS X)", + "expect" : + { + "vendor" : "Apple", + "model" : "iPhone", + "type" : "mobile" + } + }, + { + "desc" : "KTB-iPod Touch", + "ua" : "APP-BE/1.0 (iPod touch; Apple; CPU iPhone OS 7_0_2 like Mac OS X)", + "expect" : + { + "vendor" : "Apple", + "model" : "iPod touch", + "type" : "mobile" + } + }, + { + "desc" : "KTB-iPad", + "ua" : "APP-BE Test/1.0 (iPad; Apple; CPU iPhone OS 7_0_2 like Mac OS X)", + "expect" : + { + "vendor" : "Apple", + "model" : "iPad", + "type" : "tablet" + } + }, + { + "desc" : "KTB-Nexus 5", + "ua" : "APP-My App/1.0 (Linux; Android 4.2.1; Nexus 5 Build/JOP40D)", + "expect" : + { + "vendor" : "LG", + "model" : "Nexus 5", + "type" : "mobile" + } } ] diff --git a/test/engine-test.json b/test/engine-test.json index 9f6944c..23987eb 100644 --- a/test/engine-test.json +++ b/test/engine-test.json @@ -61,4 +61,24 @@ "name" : "WebKit", "version" : "533.19.4" } -}] + }, + { + "desc" : "KTA Mobile App", + "ua" : "APP-BE Test/1.0 (iPad; Apple; CPU iPhone OS 7_0_2 like Mac OS X)", + "expect" : + { + "name" : "Mobile-App", + "version" : "1.0" + } + }, + { + "desc" : "KTB-Nexus 5", + "ua" : "APP-My App/1.0 (Linux; Android 4.2.1; Nexus 5 Build/JOP40D)", + "expect" : + { + "name" : "Mobile-App", + "version" : "1.0" + } + } + +] diff --git a/test/os-test.json b/test/os-test.json index bd9769d..8ded685 100644 --- a/test/os-test.json +++ b/test/os-test.json @@ -565,4 +565,24 @@ "name" : "", "version" : "" } -}] + }, + { + "desc" : "iOS BE App", + "ua" : "APP-BE Test/1.0 (iPad; Apple; CPU iPhone OS 7_0_2 like Mac OS X)", + "expect" : + { + "name" : "iOS", + "version" : "7.0.2" + } + } + , + { + "desc" : "KTB-Nexus 5", + "ua" : "APP-My App/1.0 (Linux; Android 4.2.1; Nexus 5 Build/JOP40D)", + "expect" : + { + "name" : "Android", + "version" : "4.2.1" + } + } +] From fab1fd2ec6bbb929294f612035d024518ce67171 Mon Sep 17 00:00:00 2001 From: Sandro Sonntag Date: Fri, 30 May 2014 14:55:46 +0200 Subject: [PATCH 3/4] added bower support --- bower.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bower.json diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..68fd4a0 --- /dev/null +++ b/bower.json @@ -0,0 +1,26 @@ +{ + "name": "ua-parser", + "version": "0.6.16", + "authors": [ + "Faisal Salman " + ], + "private": false, + "main": "src/ua-parser.js", + "ignore": [ + "build", + "node_modules", + "bower_components", + "test", + "tests" + ], + "contributors": [ + "Faisal Salman ", + "Christopher De Cairos ", + "John Tantalo ", + "Jon Buckley ", + "Lee Treveil " + ], + "dependencies": { + + } +} From baf4bb99b4ef92c71419931e8fd334e34c051e52 Mon Sep 17 00:00:00 2001 From: Sandro Sonntag Date: Sat, 31 May 2014 13:01:42 +0200 Subject: [PATCH 4/4] v0.6.3-ktb --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 68fd4a0..5df1992 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { - "name": "ua-parser", - "version": "0.6.16", + "name": "ua-parser-js", + "version": "0.6.3-ktb", "authors": [ "Faisal Salman " ],