diff --git a/src/extensions/ua-parser-extensions.js b/src/extensions/ua-parser-extensions.js index 2766271..5b62e3e 100644 --- a/src/extensions/ua-parser-extensions.js +++ b/src/extensions/ua-parser-extensions.js @@ -375,8 +375,11 @@ const MediaPlayers = Object.freeze({ const Libraries = Object.freeze({ browser : [ - // Axios/jsdom/Scrapy/Java/urllib/requests - [/\b(axios|jsdom|scrapy|java|python-urllib|python-requests)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, LIBRARY]] + // Apache-HttpClient/Axios/go-http-client/got/GuzzleHttp/Java[-HttpClient]/jsdom/libwww-perl/lua-resty-http/Needle/node-fetch/OkHttp/PHP-SOAP/PostmanRuntime/python-urllib/python-requests/Scrapy/superagent + [ + /^(apache-httpclient|axios|(?:go|java)-http-client|got|guzzlehttp|java|libwww-perl|lua-resty-http|needle|node-(?:fetch|superagent)|okhttp|php-soap|postmanruntime|python-(?:urllib|requests)|scrapy)\/([\w\.]+)/i, + /(jsdom|(?<=\()java)\/([\w\.]+)/i + ], [NAME, VERSION, [TYPE, LIBRARY]] ] }); diff --git a/src/extensions/ua-parser-extensions.mjs b/src/extensions/ua-parser-extensions.mjs index 20fbee6..33f9b99 100644 --- a/src/extensions/ua-parser-extensions.mjs +++ b/src/extensions/ua-parser-extensions.mjs @@ -379,8 +379,11 @@ const MediaPlayers = Object.freeze({ const Libraries = Object.freeze({ browser : [ - // Axios/jsdom/Scrapy/Java/urllib/requests - [/\b(axios|jsdom|scrapy|java|python-urllib|python-requests)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, LIBRARY]] + // Apache-HttpClient/Axios/go-http-client/got/GuzzleHttp/Java[-HttpClient]/jsdom/libwww-perl/lua-resty-http/Needle/node-fetch/OkHttp/PHP-SOAP/PostmanRuntime/python-urllib/python-requests/Scrapy/superagent + [ + /^(apache-httpclient|axios|(?:go|java)-http-client|got|guzzlehttp|java|libwww-perl|lua-resty-http|needle|node-(?:fetch|superagent)|okhttp|php-soap|postmanruntime|python-(?:urllib|requests)|scrapy)\/([\w\.]+)/i, + /(jsdom|(?<=\()java)\/([\w\.]+)/i + ], [NAME, VERSION, [TYPE, LIBRARY]] ] }); diff --git a/test/mocha-test-extension.js b/test/mocha-test-extension.js index 6ba195b..c32c1b8 100644 --- a/test/mocha-test-extension.js +++ b/test/mocha-test-extension.js @@ -22,7 +22,7 @@ describe('Extensions', () => { .forEach((list) => { describe(list[0], () => { list[1].forEach((agent) => { - it(`Can detect ${agent.desc}`, () => { + it(`Can detect ${agent.desc}: "${agent.ua}"`, () => { let browser = UAParser(agent.ua, list[2]).browser; assert.strictEqual(String(browser.name), agent.expect.name); assert.strictEqual(String(browser.version), agent.expect.version); diff --git a/test/specs/extension/library.json b/test/specs/extension/library.json index 1ebdcdc..f691105 100644 --- a/test/specs/extension/library.json +++ b/test/specs/extension/library.json @@ -1,4 +1,14 @@ [ + { + "desc" : "Apache-HttpClient", + "ua" : "Apache-HttpClient/4.5.14 (Java/17.0.12)", + "expect" : + { + "name" : "Apache-HttpClient", + "version" : "4.5.14", + "type" : "library" + } + }, { "desc" : "Axios", "ua" : "axios/1.7.2", @@ -9,6 +19,36 @@ "type" : "library" } }, + { + "desc" : "go-http-client", + "ua" : "go-http-client/1.1", + "expect" : + { + "name" : "go-http-client", + "version" : "1.1", + "type" : "library" + } + }, + { + "desc" : "got", + "ua" : "got/9.6.0 (https://github.com/sindresorhus/got)", + "expect" : + { + "name" : "got", + "version" : "9.6.0", + "type" : "library" + } + }, + { + "desc" : "GuzzleHttp", + "ua" : "GuzzleHttp/6.5.5 curl/7.70.0 PHP/7.4.22", + "expect" : + { + "name" : "GuzzleHttp", + "version" : "6.5.5", + "type" : "library" + } + }, { "desc" : "Java", "ua" : "Java/1.6.0_14", @@ -19,6 +59,16 @@ "type" : "library" } }, + { + "desc" : "Java HTTPClient", + "ua" : "Java-http-client/11.0.6", + "expect" : + { + "name" : "Java-http-client", + "version" : "11.0.6", + "type" : "library" + } + }, { "desc" : "jsdom", "ua" : "Mozilla/5.0 (unknown OS) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/11.12.0", @@ -29,6 +79,76 @@ "type" : "library" } }, + { + "desc" : "libwww-perl", + "ua" : "libwww-perl/6.05", + "expect" : + { + "name" : "libwww-perl", + "version" : "6.05", + "type" : "library" + } + }, + { + "desc" : "lua-resty-http", + "ua" : "lua-resty-http/0.07 (Lua)", + "expect" : + { + "name" : "lua-resty-http", + "version" : "0.07", + "type" : "library" + } + }, + { + "desc" : "Needle", + "ua" : "Needle/3.2.0 (Node.js v18.14.2; win32 x64)", + "expect" : + { + "name" : "Needle", + "version" : "3.2.0", + "type" : "library" + } + }, + { + "desc" : "OkHttp", + "ua" : "okhttp/3.2.0", + "expect" : + { + "name" : "okhttp", + "version" : "3.2.0", + "type" : "library" + } + }, + { + "desc" : "node-fetch", + "ua" : "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)", + "expect" : + { + "name" : "node-fetch", + "version" : "1.0", + "type" : "library" + } + }, + { + "desc" : "PHP-SOAP", + "ua" : "PHP-SOAP/7.4.33", + "expect" : + { + "name" : "PHP-SOAP", + "version" : "7.4.33", + "type" : "library" + } + }, + { + "desc" : "PostmanRuntime", + "ua" : "PostmanRuntime/7.26.5", + "expect" : + { + "name" : "PostmanRuntime", + "version" : "7.26.5", + "type" : "library" + } + }, { "desc" : "Python urllib", "ua" : "Python-urllib/2.6", @@ -58,5 +178,15 @@ "version" : "1.5.0", "type" : "library" } + }, + { + "desc" : "superagent", + "ua" : "node-superagent/5.0.2", + "expect" : + { + "name" : "node-superagent", + "version" : "5.0.2", + "type" : "library" + } } ]