@alitu/user-agents-v2-api 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.test.js +11 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -54,7 +54,7 @@ function parseUserAgent(userAgent, referrer) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
// Attempt to lookup referrers if possible
|
|
57
|
-
if (userAgentMatch.type === 'browsers' && referrer) {
|
|
57
|
+
if ((userAgentMatch === null || userAgentMatch === void 0 ? void 0 : userAgentMatch.type) === 'browsers' && referrer) {
|
|
58
58
|
for (var _b = 0, _c = user_agents_v2_1.default.referrers; _b < _c.length; _b++) {
|
|
59
59
|
var entry = _c[_b];
|
|
60
60
|
if (referrer.match(entry.regexp)) {
|
package/dist/index.test.js
CHANGED
|
@@ -3,26 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var _1 = require(".");
|
|
4
4
|
test('identifies bots', function () {
|
|
5
5
|
var entry = (0, _1.default)('Mozilla/5.0 (compatible; HubSpot Crawler; +https://www.hubspot.com)');
|
|
6
|
-
expect(entry.name === 'HubSpot Crawler');
|
|
6
|
+
expect((entry === null || entry === void 0 ? void 0 : entry.name) === 'HubSpot Crawler');
|
|
7
7
|
});
|
|
8
8
|
test('identifies apps', function () {
|
|
9
9
|
var entry = (0, _1.default)('Overcast/3.0 (+http://overcast.fm/; iOS podcast app)');
|
|
10
|
-
expect(entry.name).toBe('Overcast');
|
|
10
|
+
expect(entry === null || entry === void 0 ? void 0 : entry.name).toBe('Overcast');
|
|
11
11
|
});
|
|
12
12
|
test('identifies libraries', function () {
|
|
13
13
|
var entry = (0, _1.default)('AppleCoreMedia/1.0.0.16G114 (iPod touch; U; CPU OS 12_4_2 like Mac OS X; en_us)');
|
|
14
|
-
expect(entry.name).toBe('AppleCoreMedia');
|
|
14
|
+
expect(entry === null || entry === void 0 ? void 0 : entry.name).toBe('AppleCoreMedia');
|
|
15
15
|
});
|
|
16
16
|
test('identifies bot libraries', function () {
|
|
17
17
|
var entry = (0, _1.default)('Apache-HttpClient/4.5.3-SNAPSHOT (Java/1.8.0_73)');
|
|
18
|
-
expect(entry.name).toBe('Apache HttpClient');
|
|
19
|
-
expect(entry.category).toBe('bot');
|
|
18
|
+
expect(entry === null || entry === void 0 ? void 0 : entry.name).toBe('Apache HttpClient');
|
|
19
|
+
expect(entry === null || entry === void 0 ? void 0 : entry.category).toBe('bot');
|
|
20
20
|
});
|
|
21
21
|
test('identifies browsers', function () {
|
|
22
22
|
var entry = (0, _1.default)('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36');
|
|
23
|
-
expect(entry.name).toBe('Chrome');
|
|
23
|
+
expect(entry === null || entry === void 0 ? void 0 : entry.name).toBe('Chrome');
|
|
24
24
|
});
|
|
25
25
|
test('identifies web apps by referrers', function () {
|
|
26
26
|
var entry = (0, _1.default)('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36', 'https://podcasts.apple.com/us/podcast/xya/id12341');
|
|
27
|
-
expect(entry.name).toBe('Apple Podcasts');
|
|
27
|
+
expect(entry === null || entry === void 0 ? void 0 : entry.name).toBe('Apple Podcasts');
|
|
28
|
+
});
|
|
29
|
+
test('returns undefined when not found', function () {
|
|
30
|
+
var entry = (0, _1.default)('Mozilla/5.0 (Toaster; Kitchen Appliances; CrumbOS 3.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 BreadBrowse/1.0', 'https://www.smartkitchen.com/recipes/perfect-toast-browser-edition');
|
|
31
|
+
expect(entry).toBeUndefined();
|
|
28
32
|
});
|