Skip to content

Commit

Permalink
Add support for YandexSearch application
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Zuev authored and pastelsky committed Feb 8, 2022
1 parent edab140 commit 7fc4018
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ function resolveUserAgent(uaString) {
// Yandex Browser uses Chromium as the udnerlying engine
strippedUA = strippedUA.replace(/YaBrowser\/(\d+\.?)+/g, '')

// Yandex Search uses Chromium as the udnerlying engine
strippedUA = strippedUA.replace(/YandexSearch\/(\d+\.?)+/g, '');

// Facebook Webview
strippedUA = strippedUA.replace(/FB_IAB/g, '').replace(/FBAN\/FBIOS/g, '');

Expand Down
4 changes: 4 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { resolveUserAgent, matchesUA, normalizeQuery } = require('../index')

const CustomUserAgentString = {
YANDEX: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 YaBrowser/18.1.1.839 Yowser/2.5 Safari/537.36',
YANDEX_SEARCH: 'Mozilla/5.0 (Linux; Android 4.4.4; GT-I9300I Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 YandexSearch/7.16',
SAMSUNG_BROWSER_7_2: 'Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG SM-N930F Build/MMB29K) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/7.2 Chrome/63.0.3239.111 Mobile Safari/537.36',
FACEBOOK_WEBVIEW_CHROME_ANDROID: 'Mozilla/5.0 (Linux; Android 8.0.0; LG-H930 Build/OPR1.170623.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 Mobile Safari/537.36 [FB_IAB/Orca-Android;FBAV/189.0.0.27.99;]',
FACEBOOK_WEBVIEW_IOS: 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508 [FBAN/FBIOS;FBAV/27.0.0.10.12;FBBV/8291884;FBDV/iPhone7,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/8.2;FBSS/3; FBCR/vodafoneIE;FBID/phone;FBLC/en_US;FBOP/5]',
Expand Down Expand Up @@ -135,6 +136,9 @@ it('resolves chrome/android properly', () => {
expect(matchesUA(CustomUserAgentString.YANDEX, { browsers: ['Chrome >= 63'] }))
.toBeTruthy()

expect(matchesUA(CustomUserAgentString.YANDEX_SEARCH, { browsers: ['Chrome >= 33'] }))
.toBeTruthy()

expect(resolveUserAgent(CustomUserAgentString.FACEBOOK_WEBVIEW_CHROME_ANDROID))
.toEqual({
family: 'Chrome',
Expand Down

0 comments on commit 7fc4018

Please sign in to comment.