-
Notifications
You must be signed in to change notification settings - Fork 29
Description
browserslist contains entries with version ranges. For instance, browserslist("ios_saf >= 9") includes the entry 'ios_saf 9.0-9.2'.
For that browserslist, browserslist-useragent matches only ios_saf 9.0. User agents with iOS Safari versions of 9.1 or 9.2 are never matched.
Steps to Repro:
const { matchesUA, resolveUserAgent } = require('browserslist-useragent')
const browserslist = require('browserslist')
ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/74.0.3729.169 Mobile/13B143 Safari/601.1.46'
console.log(resolveUserAgent(ua))
// > { family: 'iOS', version: '9.1.0' } // This is correct
console.log(matchesUA(ua, { browsers: ["ios_saf >= 9"] }))
// > false // This should be `true`
Expected behavior:
matchesUA('Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/74.0.3729.169 Mobile/13B143 Safari/601.1.46', { browsers: ["ios_saf >= 9"] }))
returns true
Actual behavior:
matchesUA('Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/74.0.3729.169 Mobile/13B143 Safari/601.1.46', { browsers: ["ios_saf >= 9"] }))
returns false
What's happening:
browserslist-useragent/index.js
Line 158 in 1cbab42
| normalizedVersion = browserVersion.split('-')[0] |
Splitting the string 'ios_saf 9.0-9.2' and taking the first array element means the only matched version is 9.0. 9.1 and 9.2 are incorrectly not matched.