diff --git a/package.json b/package.json index bdc318c..0f4af3b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "title": "UA-Parser.JS", "name": "ua-parser-js", - "version": "0.4.13", + "version": "0.4.14", "author": "Faisal Salman (http://faisalman.com)", "description": "Lightweight JavaScript-based user-agent string parser", "keywords": [ @@ -18,7 +18,7 @@ ], "main": "ua-parser", "scripts": { - "test": "./node_modules/mocha/bin/mocha" + "test": "./node_modules/mocha/bin/mocha -R spec" }, "devDependencies": { "mocha": ">= 1.7.1" diff --git a/ua-parser.js b/ua-parser.js index 4178f2b..9a29c2b 100644 --- a/ua-parser.js +++ b/ua-parser.js @@ -1,4 +1,4 @@ -// UA-Parser.JS v0.4.13 +// UA-Parser.JS v0.4.14 // Lightweight JavaScript-based User-Agent string parser // https://github.com/faisalman/ua-parser-js // @@ -152,7 +152,7 @@ /(yabrowser)\/((\d+)?[\w\.]+)/i // Yandex ], [['name', 'Yandex'], 'version', 'major'], [ - /(?:android.+(crmo|crios))\/((\d+)?[\w\.]+)/i, // Chrome for Android/iOS + /((?:android.+)crmo|crios)\/((\d+)?[\w\.]+)/i, // Chrome for Android/iOS ], [['name', 'Chrome'], 'version', 'major'], [ /version\/((\d+)?[\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile @@ -318,7 +318,7 @@ var UAParser = function UAParser (uastring) { - var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : ""); + var ua = uastring || ((global && global.navigator && global.navigator.userAgent) ? global.navigator.userAgent : ""); this.getBrowser = function () { return mapper.regex.apply(this, regexes.browser); @@ -357,13 +357,15 @@ this.setUA(ua); }; - // check whether script is running inside node.js export as module + // check js environment if (typeof exports !== 'undefined' && !/\[object\s[DOM]*Window\]/.test(global.toString())) { + // nodejs env if (typeof module !== 'undefined' && module.exports) { exports = module.exports = UAParser; } exports.UAParser = UAParser; } else { - window['UAParser'] = UAParser; + // browser env + global['UAParser'] = UAParser; } -})(this); \ No newline at end of file +})(this);