Skip to content

Commit 3356a08

Browse files
author
Robin Frischmann
committed
#127 use chrome alias for yandex
closes #127
1 parent 3d520c5 commit 3356a08

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

modules/utils/getBrowserInformation.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ function getBrowserName(browserInfo: Object): ?string {
6060
* @param {string} userAgent - userAgent that gets evaluated
6161
*/
6262
export default function getBrowserInformation(userAgent: string): Object | boolean {
63-
const browserInfo = bowser._detect(userAgent)
63+
let browserInfo = bowser._detect(userAgent)
64+
65+
if (browserInfo.yandexbrowser) {
66+
browserInfo = bowser._detect(userAgent.replace(/YaBrowser\/[0-9.]*/, ''))
67+
}
6468

6569
for (const browser in prefixByBrowser) {
6670
if (browserInfo.hasOwnProperty(browser)) {

test/dynamic/createPrefixer-test.js

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const Chrome49 = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,
1414
const SeaMonkey = 'Mozilla/5.0 (Windows NT 5.2; RW; rv:7.0a1) Gecko/20091211 SeaMonkey/9.23a1pre'
1515
const Chromium = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/50.0.2661.102 Chrome/50.0.2661.102 Safari/537.36'
1616
const PhantomJS = 'Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.0.0 Safari/538.1'
17+
const Yandex = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.137 YaBrowser/17.4.1.718 Yowser/2.5 Safari/537.36'
1718

1819
describe('Dynamic Prefixer', () => {
1920
describe('Prefixing a property', () => {
@@ -54,6 +55,12 @@ describe('Dynamic Prefixer', () => {
5455
expect(new Prefixer({ userAgent: MSIE10 }).prefix(input)).to.eql(input)
5556
})
5657
})
58+
describe('Running on Yandex', () => {
59+
it('should use Chrome version', () => {
60+
expect(new Prefixer({ userAgent: Yandex })._browserInfo.browserVersion).to.eql(57)
61+
expect(new Prefixer({ userAgent: Yandex })._browserInfo.browserName).to.eql('chrome')
62+
})
63+
})
5764
describe('Running on android < 4.4', () => {
5865
it('should use the osversion if its the native browser to check for required props', () => {
5966
const andPrefixer = new Prefixer({ userAgent: Android4_4_4 })

0 commit comments

Comments
 (0)