Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

v1.0.6

  • Loading branch information...
commit 803abd961845f61e71a8d19df1bf2e2c5c646d5d 1 parent d6eaa90
@3rd-Eden authored
View
9 CHANGELOG
@@ -1,10 +1,13 @@
+* __v1.0.6__ Updated the agent parser, JHint issues and leaking globals.
+
* __v1.0.5__ Potential fix for #11 where it doesn't install the stuff in windows
-this also brings a fresh update of the agents.js
+this also brings a fresh update of the agents.js.
* __v1.0.3__ Rewritten the `is` method so it doesn't display IE as true for
-firefox, chrome etc fixes #10 and #7
+firefox, chrome etc fixes #10 and #7.
-* __v1.0.3__ A fix for bug #6, updated the semver dependency for browserify support
+* __v1.0.3__ A fix for bug #6, updated the semver dependency for browserify
+support.
* __v1.0.2__ Don't throw errors when .parse is called without a useragent
string. It now defaults to a empty Agent instance.
View
4 bin/update.js
@@ -1,7 +1,9 @@
#!/usr/bin/env node
var updater = require('../lib/update');
-updater(function (err, data) {
+updater(function updating (err, data) {
+ "use strict";
+
if (err) return console.error('Update unsuccessfull due to errors', err.message);
// yay no issues
View
2  features/index.js
@@ -1,3 +1,5 @@
+"use strict";
+
/**
* Plugin dependencies
*/
View
2  lib/agents.js
@@ -1 +1 @@
-exports.browser = [{r:new RegExp("^(Opera)/(\\d+)\\.(\\d+) \\(Nintendo Wii"), family:"Wii"},{r:new RegExp("(SeaMonkey|Fennec|Camino)/(\\d+)\\.(\\d+)\\.?([ab]?\\d+[a-z]*)")},{r:new RegExp("(Namoroka|Shiretoko|Minefield)/(\\d+)\\.(\\d+)\\.(\\d+(?:pre)?)"), family:"Firefox ($1)"},{r:new RegExp("(Firefox)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)"), family:"Firefox Beta"},{r:new RegExp("(Firefox)-(?:\\d+\\.\\d+)?/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)"), family:"Firefox Beta"},{r:new RegExp("(Namoroka|Shiretoko|Minefield)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)?"), family:"Firefox ($1)"},{r:new RegExp("(Firefox).*Tablet browser (\\d+)\\.(\\d+)\\.(\\d+)"), family:"MicroB"},{r:new RegExp("(MozillaDeveloperPreview)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)?")},{r:new RegExp("(Flock)/(\\d+)\\.(\\d+)(b\\d+?)")},{r:new RegExp("(RockMelt)/(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(Fennec)/(\\d+)\\.(\\d+)(pre)")},{r:new RegExp("(Navigator)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Netscape"},{r:new RegExp("(Navigator)/(\\d+)\\.(\\d+)([ab]\\d+)"), family:"Netscape"},{r:new RegExp("(Netscape6)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Netscape"},{r:new RegExp("(MyIBrow)/(\\d+)\\.(\\d+)"), family:"My Internet Browser"},{r:new RegExp("(Opera Tablet).*Version\\/(\\d+)\\.(\\d+)(?:\\.(\\d+))?")},{r:new RegExp("(Opera)/.+Opera Mobi.+Version/(\\d+)\\.(\\d+)"), family:"Opera Mobile"},{r:new RegExp("(Opera Mini)/(\\d+)\\.(\\d+)")},{r:new RegExp("(Opera)/9.80.*Version\\/(\\d+)\\.(\\d+)(?:\\.(\\d+))?")},{r:new RegExp("(webOS)/(\\d+)\\.(\\d+)"), family:"Palm webOS"},{r:new RegExp("(luakit)"), family:"LuaKit"},{r:new RegExp("(Lightning)/(\\d+)\\.(\\d+)([ab]?\\d+[a-z]*)")},{r:new RegExp("(Firefox)/(\\d+)\\.(\\d+)\\.(\\d+(?:pre)?) \\(Swiftfox\\)"), family:"Swiftfox"},{r:new RegExp("(Firefox)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)? \\(Swiftfox\\)"), family:"Swiftfox"},{r:new RegExp("rekonq"), family:"Rekonq"},{r:new RegExp("(conkeror|Conkeror)/(\\d+)\\.(\\d+)\\.?(\\d+)?"), family:"Conkeror"},{r:new RegExp("(konqueror)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Konqueror"},{r:new RegExp("(PlayBook).+RIM Tablet OS (\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(WeTab)-Browser")},{r:new RegExp("(wOSBrowser).+TouchPad/(\\d+)\\.(\\d+)"), family:"webOS TouchPad"},{r:new RegExp("(Comodo_Dragon)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Comodo Dragon"},{r:new RegExp("(YottaaMonitor)")},{r:new RegExp("(Kindle)/(\\d+)\\.(\\d+)")},{r:new RegExp("(AdobeAIR|Chromium|FireWeb|Jasmine|ANTGalio|Midori|Fresco|Lobo|PaleMoon|Maxthon|Lynx|OmniWeb|Dillo|Camino|Demeter|Fluid|Fennec|Shiira|Sunrise|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|Vodafone|NetFront|Konqueror|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|Opera Mini|iCab|NetNewsWire|ThunderBrowse|Iron|Iris)/(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(Bolt|Jasmine|IceCat|Skyfire|Midori|Maxthon|Lynx|Arora|IBrowse|Dillo|Camino|Shiira|Fennec|Phoenix|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|Opera Mini|Opera|Vodafone|NetFront|Konqueror|Googlebot|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|iCab|NetNewsWire|Iron|Space Bison|Stainless|Orca|Dolfin|BOLT)/(\\d+)\\.(\\d+)")},{r:new RegExp("(iRider|Crazy Browser|SkipStone|iCab|Lunascape|Sleipnir|Maemo Browser) (\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(iCab|Lunascape|Opera|Android) (\\d+)\\.(\\d+)\\.?(\\d+)?")},{r:new RegExp("(IEMobile)[ /](\\d+)\\.(\\d+)"), family:"IE Mobile"},{r:new RegExp("(MSIE) (\\d+)\\.(\\d+).*XBLWP7"), family:"IE Mobile"},{r:new RegExp("(Firefox)/(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(Firefox)/(\\d+)\\.(\\d+)(pre|[ab]\\d+[a-z]*)?")},{r:new RegExp("(Obigo|OBIGO)[^\\d]*(\\d+)(?:.(\\d+))?"), family:"Obigo"},{r:new RegExp("(MAXTHON|Maxthon) (\\d+)\\.(\\d+)"), family:"Maxthon"},{r:new RegExp("(Maxthon|MyIE2|Uzbl|Shiira)")},{r:new RegExp("(PLAYSTATION) (\\d+)"), family:"PlayStation"},{r:new RegExp("(PlayStation Portable)[^\\d]+(\\d+).(\\d+)")},{r:new RegExp("(BrowseX) \\((\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(POLARIS)/(\\d+)\\.(\\d+)"), family:"Polaris"},{r:new RegExp("(BonEcho)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Bon Echo"},{r:new RegExp("(iPod).+Version/(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(iPhone) OS (\\d+)_(\\d+)(?:_(\\d+))?")},{r:new RegExp("(iPad).+ OS (\\d+)_(\\d+)(?:_(\\d+))?")},{r:new RegExp("(Avant)")},{r:new RegExp("(Nokia)[EN]?(\\d+)")},{r:new RegExp("(Black[bB]erry).+Version\\/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Blackberry"},{r:new RegExp("(Black[bB]erry)\\s?(\\d+)"), family:"Blackberry"},{r:new RegExp("(OmniWeb)/v(\\d+)\\.(\\d+)")},{r:new RegExp("(Blazer)/(\\d+)\\.(\\d+)"), family:"Palm Blazer"},{r:new RegExp("(Pre)/(\\d+)\\.(\\d+)"), family:"Palm Pre"},{r:new RegExp("(Links) \\((\\d+)\\.(\\d+)")},{r:new RegExp("(QtWeb) Internet Browser/(\\d+)\\.(\\d+)")},{r:new RegExp("(Silk)/(\\d+)\\.(\\d+)(?:\\.([0-9\\-]+))?")},{r:new RegExp("(Version)/(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*Safari/"), family:"Safari"},{r:new RegExp("(Safari)/\\d+")},{r:new RegExp("(OLPC)/Update(\\d+)\\.(\\d+)")},{r:new RegExp("(OLPC)/Update()\\.(\\d+)")},{r:new RegExp("(SamsungSGHi560)"), family:"Samsung SGHi560"},{r:new RegExp("^(SonyEricssonK800i)"), family:"Sony Ericsson K800i"},{r:new RegExp("(Teleca Q7)")},{r:new RegExp("(MSIE) (\\d+)\\.(\\d+)"), family:"IE"},{r:new RegExp("(Thunderbird)/(\\d+)\\.(\\d+)\\.?(\\d+)?")},{r:new RegExp("(Wget)/(\\d+)\\.(\\d+)\\.?([ab]?\\d+[a-z]*)")},{r:new RegExp("(curl)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"cURL"}];exports.os = [{r:new RegExp("(Windows (?:NT 5\\.2|NT 5\\.1))"), os:"Windows XP"},{r:new RegExp("(XBLWP7)"), os:"Windows Phone OS"},{r:new RegExp("(Windows NT 6\\.1)"), os:"Windows 7"},{r:new RegExp("(Windows NT 6\\.0)"), os:"Windows Vista"},{r:new RegExp("(Windows 98|Windows XP|Windows ME|Windows 95|Windows CE|Windows 7|Windows NT 4\\.0|Windows Vista|Windows 2000)")},{r:new RegExp("(Windows NT 6\\.2)"), os:"Windows 8"},{r:new RegExp("(Windows NT 5\\.0)"), os:"Windows 2000"},{r:new RegExp("(Windows Phone OS) (\\d+)\\.(\\d+)")},{r:new RegExp("(Windows ?Mobile)"), os:"Windows Mobile"},{r:new RegExp("(WinNT4.0)"), os:"Windows NT 4.0"},{r:new RegExp("(Win98)"), os:"Windows 98"},{r:new RegExp("(Android) (\\d+)\\.(\\d+)(?:[.\\-]([a-z0-9]+))?")},{r:new RegExp("(Android) Donut")},{r:new RegExp("(Android) Eclair")},{r:new RegExp("(Android) Froyo")},{r:new RegExp("(Android) Gingerbread")},{r:new RegExp("(Android) Honeycomb")},{r:new RegExp("(Mac OS X) (\\d+)[_.](\\d+)(?:[_.](\\d+))?")},{r:new RegExp("(?:PPC|Intel) (Mac OS X)")},{r:new RegExp("(CPU OS|iPhone OS) (\\d+)_(\\d+)(?:_(\\d+))?"), os:"iOS"},{r:new RegExp("(iPhone|iPad|iPod); Opera"), os:"iOS"},{r:new RegExp("(iPhone|iPad|iPod).*Mac OS X"), os:"iOS"},{r:new RegExp("(CrOS) [a-z0-9_]+ (\\d+)\\.(\\d+)(?:\\.(\\d+))?"), os:"Chrome OS"},{r:new RegExp("(Debian)-(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?")},{r:new RegExp("(Linux Mint)(?:/(\\d+))?")},{r:new RegExp("(Mandriva)(?: Linux)?/(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?")},{r:new RegExp("(Symbian[Oo][Ss])/(\\d+)\\.(\\d+)"), os:"Symbian OS"},{r:new RegExp("(Symbian/3)"), os:"Symbian^3"},{r:new RegExp("(Series 60|SymbOS|S60)"), os:"Symbian OS"},{r:new RegExp("(Black[Bb]erry)[0-9a-z]+/(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?"), os:"BlackBerry OS"},{r:new RegExp("(Black[Bb]erry).+Version/(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?"), os:"BlackBerry OS"},{r:new RegExp("(RIM Tablet OS) (\\d+)\\.(\\d+)\\.(\\d+)"), os:"BlackBerry Tablet OS"},{r:new RegExp("(Play[Bb]ook)"), os:"BlackBerry Tablet OS"},{r:new RegExp("(Black[Bb]erry)"), os:"Blackberry OS"},{r:new RegExp("(webOS|hpwOS)/(\\d+)\\.(\\d+)(?:\\.(\\d+))?"), os:"webOS"},{r:new RegExp("(SUSE|Fedora|Red Hat|PCLinuxOS)/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(SUSE|Fedora|Red Hat|Puppy|PCLinuxOS|CentOS)/(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(Ubuntu|Kindle|Bada|Lubuntu|BackTrack|Red Hat|Slackware)/(\\d+)\\.(\\d+)")},{r:new RegExp("(Windows|OpenBSD|FreeBSD|NetBSD|Ubuntu|Kubuntu|Android|Arch Linux|CentOS|WeTab|Slackware)")},{r:new RegExp("(Linux|BSD)")},{r:new RegExp("(Red Hat)")}];
+exports.browser = [{r:new RegExp("^(Opera)/(\\d+)\\.(\\d+) \\(Nintendo Wii"), family:"Wii"},{r:new RegExp("(SeaMonkey|Fennec|Camino)/(\\d+)\\.(\\d+)\\.?([ab]?\\d+[a-z]*)")},{r:new RegExp("(Namoroka|Shiretoko|Minefield)/(\\d+)\\.(\\d+)\\.(\\d+(?:pre)?)"), family:"Firefox ($1)"},{r:new RegExp("(Firefox)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)"), family:"Firefox Beta"},{r:new RegExp("(Firefox)-(?:\\d+\\.\\d+)?/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)"), family:"Firefox Beta"},{r:new RegExp("(Namoroka|Shiretoko|Minefield)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)?"), family:"Firefox ($1)"},{r:new RegExp("(Firefox).*Tablet browser (\\d+)\\.(\\d+)\\.(\\d+)"), family:"MicroB"},{r:new RegExp("(MozillaDeveloperPreview)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)?")},{r:new RegExp("(Flock)/(\\d+)\\.(\\d+)(b\\d+?)")},{r:new RegExp("(RockMelt)/(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(Fennec)/(\\d+)\\.(\\d+)(pre)")},{r:new RegExp("(Navigator)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Netscape"},{r:new RegExp("(Navigator)/(\\d+)\\.(\\d+)([ab]\\d+)"), family:"Netscape"},{r:new RegExp("(Netscape6)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Netscape"},{r:new RegExp("(MyIBrow)/(\\d+)\\.(\\d+)"), family:"My Internet Browser"},{r:new RegExp("(Opera Tablet).*Version\\/(\\d+)\\.(\\d+)(?:\\.(\\d+))?")},{r:new RegExp("(Opera)/.+Opera Mobi.+Version/(\\d+)\\.(\\d+)"), family:"Opera Mobile"},{r:new RegExp("(Opera Mini)/(\\d+)\\.(\\d+)")},{r:new RegExp("(Opera)/9.80.*Version\\/(\\d+)\\.(\\d+)(?:\\.(\\d+))?")},{r:new RegExp("(webOS)/(\\d+)\\.(\\d+)"), family:"Palm webOS"},{r:new RegExp("(luakit)"), family:"LuaKit"},{r:new RegExp("(Lightning)/(\\d+)\\.(\\d+)([ab]?\\d+[a-z]*)")},{r:new RegExp("(Firefox)/(\\d+)\\.(\\d+)\\.(\\d+(?:pre)?) \\(Swiftfox\\)"), family:"Swiftfox"},{r:new RegExp("(Firefox)/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*)? \\(Swiftfox\\)"), family:"Swiftfox"},{r:new RegExp("rekonq"), family:"Rekonq"},{r:new RegExp("(conkeror|Conkeror)/(\\d+)\\.(\\d+)\\.?(\\d+)?"), family:"Conkeror"},{r:new RegExp("(konqueror)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Konqueror"},{r:new RegExp("(PlayBook).+RIM Tablet OS (\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(WeTab)-Browser")},{r:new RegExp("(wOSBrowser).+TouchPad/(\\d+)\\.(\\d+)"), family:"webOS TouchPad"},{r:new RegExp("(Comodo_Dragon)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Comodo Dragon"},{r:new RegExp("(YottaaMonitor)")},{r:new RegExp("(Kindle)/(\\d+)\\.(\\d+)")},{r:new RegExp("(CrMo)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Chrome Mobile"},{r:new RegExp("(AdobeAIR|Chromium|FireWeb|Jasmine|ANTGalio|Midori|Fresco|Lobo|PaleMoon|Maxthon|Lynx|OmniWeb|Dillo|Camino|Demeter|Fluid|Fennec|Shiira|Sunrise|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|Vodafone|NetFront|Konqueror|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|Opera Mini|iCab|NetNewsWire|ThunderBrowse|Iron|Iris)/(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(Bolt|Jasmine|IceCat|Skyfire|Midori|Maxthon|Lynx|Arora|IBrowse|Dillo|Camino|Shiira|Fennec|Phoenix|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|Opera Mini|Opera|Vodafone|NetFront|Konqueror|Googlebot|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|iCab|NetNewsWire|Iron|Space Bison|Stainless|Orca|Dolfin|BOLT)/(\\d+)\\.(\\d+)")},{r:new RegExp("(iRider|Crazy Browser|SkipStone|iCab|Lunascape|Sleipnir|Maemo Browser) (\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(iCab|Lunascape|Opera|Android) (\\d+)\\.(\\d+)\\.?(\\d+)?")},{r:new RegExp("(IEMobile)[ /](\\d+)\\.(\\d+)"), family:"IE Mobile"},{r:new RegExp("(MSIE) (\\d+)\\.(\\d+).*XBLWP7"), family:"IE Mobile"},{r:new RegExp("(Firefox)/(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(Firefox)/(\\d+)\\.(\\d+)(pre|[ab]\\d+[a-z]*)?")},{r:new RegExp("(Obigo|OBIGO)[^\\d]*(\\d+)(?:.(\\d+))?"), family:"Obigo"},{r:new RegExp("(MAXTHON|Maxthon) (\\d+)\\.(\\d+)"), family:"Maxthon"},{r:new RegExp("(Maxthon|MyIE2|Uzbl|Shiira)")},{r:new RegExp("(PLAYSTATION) (\\d+)"), family:"PlayStation"},{r:new RegExp("(PlayStation Portable)[^\\d]+(\\d+).(\\d+)")},{r:new RegExp("(BrowseX) \\((\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(POLARIS)/(\\d+)\\.(\\d+)"), family:"Polaris"},{r:new RegExp("(BonEcho)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Bon Echo"},{r:new RegExp("(iPod).+Version/(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(iPhone) OS (\\d+)_(\\d+)(?:_(\\d+))?")},{r:new RegExp("(iPad).+ OS (\\d+)_(\\d+)(?:_(\\d+))?")},{r:new RegExp("(Avant)")},{r:new RegExp("(Nokia)[EN]?(\\d+)")},{r:new RegExp("(Black[bB]erry).+Version\\/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"Blackberry"},{r:new RegExp("(Black[bB]erry)\\s?(\\d+)"), family:"Blackberry"},{r:new RegExp("(OmniWeb)/v(\\d+)\\.(\\d+)")},{r:new RegExp("(Blazer)/(\\d+)\\.(\\d+)"), family:"Palm Blazer"},{r:new RegExp("(Pre)/(\\d+)\\.(\\d+)"), family:"Palm Pre"},{r:new RegExp("(Links) \\((\\d+)\\.(\\d+)")},{r:new RegExp("(QtWeb) Internet Browser/(\\d+)\\.(\\d+)")},{r:new RegExp("(Silk)/(\\d+)\\.(\\d+)(?:\\.([0-9\\-]+))?")},{r:new RegExp("(Version)/(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*Safari/"), family:"Safari"},{r:new RegExp("(Safari)/\\d+")},{r:new RegExp("(OLPC)/Update(\\d+)\\.(\\d+)")},{r:new RegExp("(OLPC)/Update()\\.(\\d+)")},{r:new RegExp("(SamsungSGHi560)"), family:"Samsung SGHi560"},{r:new RegExp("^(SonyEricssonK800i)"), family:"Sony Ericsson K800i"},{r:new RegExp("(Teleca Q7)")},{r:new RegExp("(MSIE) (\\d+)\\.(\\d+)"), family:"IE"},{r:new RegExp("(Thunderbird)/(\\d+)\\.(\\d+)\\.?(\\d+)?")},{r:new RegExp("(Wget)/(\\d+)\\.(\\d+)\\.?([ab]?\\d+[a-z]*)")},{r:new RegExp("(curl)/(\\d+)\\.(\\d+)\\.(\\d+)"), family:"cURL"}];exports.os = [{r:new RegExp("(Windows (?:NT 5\\.2|NT 5\\.1))"), os:"Windows XP"},{r:new RegExp("(XBLWP7)"), os:"Windows Phone OS"},{r:new RegExp("(Windows NT 6\\.1)"), os:"Windows 7"},{r:new RegExp("(Windows NT 6\\.0)"), os:"Windows Vista"},{r:new RegExp("(Windows 98|Windows XP|Windows ME|Windows 95|Windows CE|Windows 7|Windows NT 4\\.0|Windows Vista|Windows 2000)")},{r:new RegExp("(Windows NT 6\\.2)"), os:"Windows 8"},{r:new RegExp("(Windows NT 5\\.0)"), os:"Windows 2000"},{r:new RegExp("(Windows Phone OS) (\\d+)\\.(\\d+)")},{r:new RegExp("(Windows ?Mobile)"), os:"Windows Mobile"},{r:new RegExp("(WinNT4.0)"), os:"Windows NT 4.0"},{r:new RegExp("(Win98)"), os:"Windows 98"},{r:new RegExp("(Android) (\\d+)\\.(\\d+)(?:[.\\-]([a-z0-9]+))?")},{r:new RegExp("(Android) Donut")},{r:new RegExp("(Android) Eclair")},{r:new RegExp("(Android) Froyo")},{r:new RegExp("(Android) Gingerbread")},{r:new RegExp("(Android) Honeycomb")},{r:new RegExp("(Mac OS X) (\\d+)[_.](\\d+)(?:[_.](\\d+))?")},{r:new RegExp("(?:PPC|Intel) (Mac OS X)")},{r:new RegExp("(CPU OS|iPhone OS) (\\d+)_(\\d+)(?:_(\\d+))?"), os:"iOS"},{r:new RegExp("(iPhone|iPad|iPod); Opera"), os:"iOS"},{r:new RegExp("(iPhone|iPad|iPod).*Mac OS X"), os:"iOS"},{r:new RegExp("(CrOS) [a-z0-9_]+ (\\d+)\\.(\\d+)(?:\\.(\\d+))?"), os:"Chrome OS"},{r:new RegExp("(Debian)-(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?")},{r:new RegExp("(Linux Mint)(?:/(\\d+))?")},{r:new RegExp("(Mandriva)(?: Linux)?/(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?")},{r:new RegExp("(Symbian[Oo][Ss])/(\\d+)\\.(\\d+)"), os:"Symbian OS"},{r:new RegExp("(Symbian/3)"), os:"Symbian^3"},{r:new RegExp("(Series 60|SymbOS|S60)"), os:"Symbian OS"},{r:new RegExp("(Black[Bb]erry)[0-9a-z]+/(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?"), os:"BlackBerry OS"},{r:new RegExp("(Black[Bb]erry).+Version/(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\d+))?"), os:"BlackBerry OS"},{r:new RegExp("(RIM Tablet OS) (\\d+)\\.(\\d+)\\.(\\d+)"), os:"BlackBerry Tablet OS"},{r:new RegExp("(Play[Bb]ook)"), os:"BlackBerry Tablet OS"},{r:new RegExp("(Black[Bb]erry)"), os:"Blackberry OS"},{r:new RegExp("(webOS|hpwOS)/(\\d+)\\.(\\d+)(?:\\.(\\d+))?"), os:"webOS"},{r:new RegExp("(SUSE|Fedora|Red Hat|PCLinuxOS)/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(SUSE|Fedora|Red Hat|Puppy|PCLinuxOS|CentOS)/(\\d+)\\.(\\d+)\\.(\\d+)")},{r:new RegExp("(Ubuntu|Kindle|Bada|Lubuntu|BackTrack|Red Hat|Slackware)/(\\d+)\\.(\\d+)")},{r:new RegExp("(Windows|OpenBSD|FreeBSD|NetBSD|Ubuntu|Kubuntu|Android|Arch Linux|CentOS|WeTab|Slackware)")},{r:new RegExp("(Linux|BSD)")},{r:new RegExp("(Red Hat)")}];
View
12 lib/update.js
@@ -1,3 +1,5 @@
+"use strict";
+
var request = require('request')
, yaml = require('yamlparser')
, path = require('path')
@@ -27,8 +29,8 @@ module.exports = function update (fn) {
// try to see if we can parse the yaml
var parsed_yaml;
- try { parsed_yaml = yaml.eval(yamlstring) }
- catch (e) { return false }
+ try { parsed_yaml = yaml.eval(yamlstring); }
+ catch (e) { return false; }
// make sure we have a correct structure because we are reading this from
// a remote resource, they might change the structure of the JSON
@@ -39,7 +41,7 @@ module.exports = function update (fn) {
|| !('os_parsers' in parsed_yaml)
|| !parsed_yaml.os_parsers.length
|| !parsed_yaml.os_parsers[0].regex
- ) return false;
+ ) return false;
// \o/ working, now to create pre-compiled version of the regexps
// now we can try to generate a smaller file so it will take less memory
@@ -96,8 +98,8 @@ module.exports = function update (fn) {
// have been naught with our internet and injected a require() statment in
// the codez, paranoid ftw
var sandbox = { exports: {} };
- try { vm.runInNewContext(agentjs, sandbox, 'agentjs.vm') }
- catch (e) { return fn(e) }
+ try { vm.runInNewContext(agentjs, sandbox, 'agentjs.vm'); }
+ catch (e) { return fn(e); }
fn(null, sandbox.exports);
View
34 lib/useragent.js
@@ -1,3 +1,5 @@
+"use strict";
+
/**
* Library dependencies.
*/
@@ -142,7 +144,7 @@ function parse (useragent, jsagent) {
(jsagent.indexOf('Chrome/') !== -1 && useragent.indexOf('chromeframe') !== -1)
) {
ua[1] = 'Chrome Frame (' + ua[1] + ' ' + ua[2] + ')';
- parser = parse(jsagent);
+ var parser = parse(jsagent);
// update to the new correct version numbers of chrome frame
ua[2] = parser.major;
@@ -175,19 +177,19 @@ function updater (refresh) {
// check if we need to refresh the code from the live servers this does not
// impact the rest of the library, it will just update the `agents` code.
if (refresh) {
- require('./update')(function (err, set) {
+ require('./update')(function updating (err, set) {
if (err) return; // use old set on error
// update our agents and lenghts
agents = set;
// update the references to the browsers
- browsers = agents.browser;
- oss = agents.os;
+ parse.browsers = agents.browser;
+ parse.os = agents.os;
// count the browsers and operating systems again
- ua_length = browsers.length;
- os_length = oss.length;
+ parse.ua_length = parse.browsers.length;
+ parse.os_length = parse.os.length;
});
}
}
@@ -267,8 +269,8 @@ function fromString (prettyAgent) {
return new Agent(partition[0]
, versions[0]
, versions[1]
- , partition.length == 3 ? partitition[2] : versions[2]
- , parts.length == 2 ? parts[1] : null
+ , partition.length === 3 ? partition[2] : versions[2]
+ , parts.length === 2 ? parts[1] : null
);
}
@@ -297,7 +299,7 @@ function dictionary (ua, jsua) {
, match = dictionary.lookup[key];
if (match) return match;
- return (dictionary.lookup[key] = parse(ua, jsua))
+ return (dictionary.lookup[key] = parse(ua, jsua));
}
/**
@@ -310,12 +312,6 @@ function dictionary (ua, jsua) {
dictionary.lookup = {};
/**
- * Library version.
- */
-
-updater.version = '1.0.5';
-
-/**
* Expose the Agent constructor.
*
* @api private
@@ -364,6 +360,14 @@ updater.fromJSON = fromJSON;
updater.is = is;
/**
+ * Library version.
+ *
+ * @api public
+ */
+
+updater.version = '1.0.5';
+
+/**
* Expose the updater.
*
* @api public
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "useragent"
- , "version": "1.0.5"
+ , "version": "1.0.6"
, "description": "User-Agent string parser based on Browserscope.org algorithms for more browser reporting"
, "author": "Arnout Kazemier"
, "main": "./index.js"
Please sign in to comment.
Something went wrong with that request. Please try again.