Skip to content

Commit

Permalink
feat(ua): catch more bots
Browse files Browse the repository at this point in the history
  • Loading branch information
wessberg committed May 21, 2021
1 parent 45c9918 commit 7ec729c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/browserslist-generator/ua-parser-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ extend([
"bitdiscovery",
"Dalvik/",
"placid.app/v1",
"WebsiteMetadataRetriever"
"WebsiteMetadataRetriever",
"(compatible; aa/1.0)"
]);

// These extension provide ua-parser-js with support for additional browsers
Expand Down
13 changes: 13 additions & 0 deletions test/browserslist-generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ test("matchBrowserslistOnUserAgent() => Will match the Instagram browser on iOS
t.true(matchBrowserslistOnUserAgent(`Instagram 187.0.0.32.120 (iPhone7,2; iOS 12_4_9; sv_SE; sv-SE; scale=2.00; 750x1334; 289678855) AppleWebKit/420+`, ["ios_saf >= 12"]));
});

test("matchBrowserslistOnUserAgent() => Will match the Instagram browser on iOS and detect it as iOS Safari. #2", t => {
t.true(matchBrowserslistOnUserAgent(`Instagram 187.0.0.32.120 (iPhone9,4; iOS 13_7; es_CO; es-ES; scale=2.61; 1080x1920; 289678855) AppleWebKit/420+`, ["ios_saf >= 13"]));
});

test("matchBrowserslistOnUserAgent() => Will match non-Chromium based MiuiBrowser on Android. #1", t => {
t.true(
matchBrowserslistOnUserAgent(
Expand Down Expand Up @@ -267,6 +271,15 @@ test("matchBrowserslistOnUserAgent() => Will match random bots as IE 11. #5", t
);
});

test("matchBrowserslistOnUserAgent() => Will match random bots as IE 11. #6", t => {
t.true(
matchBrowserslistOnUserAgent(
`Mozilla/5.0 (compatible; aa/1.0)`,
["ie >= 11"]
)
);
});

test("matchBrowserslistOnUserAgent() => Will match BingBot as IE 11", t => {
t.true(matchBrowserslistOnUserAgent(bingBot(), ["ie >= 11"]));
});
Expand Down

0 comments on commit 7ec729c

Please sign in to comment.