-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
browserslist has the ability to use supports [feature] to query against caniuse features.
So something like this also works with browserslist-useragent:
matchesUA(
'Mozilla/5.0 (Windows NT 10.0; rv:54.0) Gecko/20100101 Firefox/54.0',
{ browsers: ['supports es6-module'] }
)
It however fails if the feature to test for contains a key listed in:
browserslist-useragent/index.ts
Lines 10 to 24 in b767e4d
| const browserNameMap: Record<string, string> = { | |
| bb: 'BlackBerry', | |
| and_chr: 'Chrome', | |
| ChromeAndroid: 'Chrome', | |
| FirefoxAndroid: 'Firefox', | |
| ff: 'Firefox', | |
| ie_mob: 'ExplorerMobile', | |
| ie: 'Explorer', | |
| and_ff: 'Firefox', | |
| ios_saf: 'iOS', | |
| op_mini: 'OperaMini', | |
| op_mob: 'OperaMobile', | |
| and_qq: 'QQAndroid', | |
| and_uc: 'UCAndroid', | |
| } |
Like for example woff or woff2, this is due to
browserslist-useragent/index.ts
Lines 160 to 170 in b767e4d
| function normalizeQuery(query: string) { | |
| let normalizedQuery = query | |
| const regex = `(${Object.keys(browserNameMap).join('|')})` | |
| const match = query.match(new RegExp(regex)) | |
| if (match) { | |
| normalizedQuery = query.replace(match[0], browserNameMap[match[0]]) | |
| } | |
| return normalizedQuery | |
| } |
Is there some way to make { browsers: ['supports woff2'] } and working?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels