From 9a90d932cef634b97e68c28c46e2ceaadbf3d343 Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Mon, 28 Jan 2013 18:35:51 +0700 Subject: [PATCH] Add new OS: Firefox OS --- package.json | 2 +- readme.md | 4 ++-- test.js | 9 +++++++++ ua-parser.js | 9 ++++++--- ua-parser.min.js | 4 ++-- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 1ee952e..62ff569 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "title": "UA-Parser.JS", "name": "ua-parser-js", - "version": "0.5.1", + "version": "0.5.2", "author": "Faisal Salman (http://faisalman.com)", "description": "Lightweight JavaScript-based user-agent string parser", "keywords": [ diff --git a/readme.md b/readme.md index 2751a77..0e44ec5 100644 --- a/readme.md +++ b/readme.md @@ -65,7 +65,7 @@ Extract detailed type of web browser, layout engine, operating system, and devic console.log(parser.getResult().browser); // {name: "Chromium", major: "15", version: "15.0.874.106"} console.log(parser.getResult().device); // {model: undefined, type: undefined, vendor: undefined} - console.log(parser.getResult().engine); // {name: "AppleWebKit", version: "535.2"} + console.log(parser.getResult().engine); // {name: "WebKit", version: "535.2"} console.log(parser.getResult().os); // {name: "Ubuntu", version: "11.10"} // let's take another test please @@ -88,7 +88,7 @@ var uaString = 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWe console.log(parser.setUA(uaString).getDevice().model); // "PlayBook" console.log(parser.getOS()) // {name: "RIM Tablet OS", version: "1.0.0"} -console.log(parser.getEngine().name); // "AppleWebKit" +console.log(parser.getEngine().name); // "WebKit" ``` ## License diff --git a/test.js b/test.js index d3605ff..8f22fbc 100644 --- a/test.js +++ b/test.js @@ -896,6 +896,15 @@ var os = [ version : '' } }, + { + desc : 'Firefox OS', + ua : 'Mozilla/5.0 (Mobile; rv:14.0) Gecko/14.0 Firefox/14.0', + expect : + { + name : 'Firefox OS', + version : undefined + } + }, { desc : 'Nintendo', ua : '', diff --git a/ua-parser.js b/ua-parser.js index aa66baf..ae1fe3c 100644 --- a/ua-parser.js +++ b/ua-parser.js @@ -1,4 +1,4 @@ -// UA-Parser.JS v0.5.1 +// UA-Parser.JS v0.5.2 // Lightweight JavaScript-based User-Agent string parser // https://github.com/faisalman/ua-parser-js // @@ -12,13 +12,13 @@ var EMPTY = '', FUNC = 'function', UNDEF = 'undefined', - OBJ = 'object', + OBJ = 'object', MAJOR = 'major', MODEL = 'model', NAME = 'name', TYPE = 'type', VENDOR = 'vendor', - VERSION = 'version', + VERSION = 'version', CONSOLE = 'console', MOBILE = 'mobile', TABLET = 'tablet'; @@ -318,7 +318,10 @@ ], [NAME, VERSION], [ /(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i // Symbian ], [[NAME, 'Symbian'], VERSION],[ + /mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS + ], [[NAME, 'Firefox OS'], VERSION], [ + // Console /(nintendo|playstation)\s([wids3portablev]+)/i, // Nintendo/Playstation // GNU/Linux based diff --git a/ua-parser.min.js b/ua-parser.min.js index 8f3409b..545942d 100644 --- a/ua-parser.min.js +++ b/ua-parser.min.js @@ -1,7 +1,7 @@ -// UA-Parser.JS v0.5.1 +// UA-Parser.JS v0.5.2 // Lightweight JavaScript-based User-Agent string parser // https://github.com/faisalman/ua-parser-js // // Copyright © 2012 Faisalman // Dual licensed under GPLv2 & MIT -(function(e,t){"use strict";var n="",r="function",i="undefined",s="object",o="major",u="model",a="name",f="type",l="vendor",c="version",h="console",p="mobile",d="tablet",v={regex:function(){var e,o,u,a,f,l,c=arguments;for(o=0;o0){for(var o=0;o0){for(var o=0;o