Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cover query case-insensitive #648

Merged
merged 1 commit into from Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -642,7 +642,7 @@ function coverQuery(context, coverage, statMode) {
coverage = parseFloat(coverage)
var usage = browserslist.usage.global
if (statMode) {
if (statMode.match(/^my\s+stats$/)) {
if (statMode.match(/^my\s+stats$/i)) {
if (!context.customUsage) {
throw new BrowserslistError('Custom usage statistics was not provided')
}
Expand Down Expand Up @@ -916,11 +916,11 @@ var QUERIES = [
}
},
{
regexp: /^cover\s+(\d+|\d+\.\d+|\.\d+)%$/,
regexp: /^cover\s+(\d+|\d+\.\d+|\.\d+)%$/i,
select: coverQuery
},
{
regexp: /^cover\s+(\d+|\d+\.\d+|\.\d+)%\s+in\s+(my\s+stats|(alt-)?\w\w)$/,
regexp: /^cover\s+(\d+|\d+\.\d+|\.\d+)%\s+in\s+(my\s+stats|(alt-)?\w\w)$/i,
select: coverQuery
},
{
Expand Down
13 changes: 13 additions & 0 deletions test/cover.test.js
Expand Up @@ -32,10 +32,18 @@ it('adds at least one browser', () => {
expect(browserslist('cover 1% in my stats')).toEqual(['ie 11'])
})

it('is case insensitive for custom stat', () => {
expect(browserslist('Cover 1% In My Stats')).toEqual(['ie 11'])
})

it('global coverage', () => {
expect(browserslist('cover 0.1%')).toEqual(['ie 5'])
})

it('is case insensitive for global coverage', () => {
expect(browserslist('Cover 0.1%')).toEqual(['ie 5'])
})

it('country coverage', () => {
expect(browserslist('cover 0.1% in US')).toEqual(['ie 9'])
})
Expand All @@ -44,6 +52,11 @@ it('country coverage alt', () => {
expect(browserslist('cover 0.1% in alt-us')).toEqual(['ie 8'])
})

it('is case insensitive for country coverage', () => {
expect(browserslist('Cover 0.1% in us')).toEqual(['ie 9'])
expect(browserslist('Cover 0.1% in Alt-US')).toEqual(['ie 8'])
})

it('adds browsers by popularity', () => {
expect(browserslist('cover 20% in my stats')).toEqual([
'chrome 37',
Expand Down