Skip to content

Commit

Permalink
#127 use chrome alias for yandex
Browse files Browse the repository at this point in the history
closes #127
  • Loading branch information
Robin Frischmann committed May 22, 2017
1 parent 3d520c5 commit 3356a08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/utils/getBrowserInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ function getBrowserName(browserInfo: Object): ?string {
* @param {string} userAgent - userAgent that gets evaluated
*/
export default function getBrowserInformation(userAgent: string): Object | boolean {
const browserInfo = bowser._detect(userAgent)
let browserInfo = bowser._detect(userAgent)

if (browserInfo.yandexbrowser) {
browserInfo = bowser._detect(userAgent.replace(/YaBrowser\/[0-9.]*/, ''))
}

for (const browser in prefixByBrowser) {
if (browserInfo.hasOwnProperty(browser)) {
Expand Down
7 changes: 7 additions & 0 deletions test/dynamic/createPrefixer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const Chrome49 = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,
const SeaMonkey = 'Mozilla/5.0 (Windows NT 5.2; RW; rv:7.0a1) Gecko/20091211 SeaMonkey/9.23a1pre'
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'
const PhantomJS = 'Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.0.0 Safari/538.1'
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'

describe('Dynamic Prefixer', () => {
describe('Prefixing a property', () => {
Expand Down Expand Up @@ -54,6 +55,12 @@ describe('Dynamic Prefixer', () => {
expect(new Prefixer({ userAgent: MSIE10 }).prefix(input)).to.eql(input)
})
})
describe('Running on Yandex', () => {
it('should use Chrome version', () => {
expect(new Prefixer({ userAgent: Yandex })._browserInfo.browserVersion).to.eql(57)
expect(new Prefixer({ userAgent: Yandex })._browserInfo.browserName).to.eql('chrome')
})
})
describe('Running on android < 4.4', () => {
it('should use the osversion if its the native browser to check for required props', () => {
const andPrefixer = new Prefixer({ userAgent: Android4_4_4 })
Expand Down

0 comments on commit 3356a08

Please sign in to comment.