Skip to content

Commit d596dc6

Browse files
authored
Merge pull request #935 from swwind/fix-baseline-case-insensitive
Fix: treat baseline newly/widely available keywords case-insensitively
2 parents ef1895c + 796ee66 commit d596dc6

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,8 @@ var QUERIES = {
829829
var baselineVersions
830830
var includeDownstream = !!node.downstream
831831
var includeKaiOS = !!node.kaios
832-
if (node.availability === 'newly' && node.date) {
832+
var availability = node.availability && node.availability.toLowerCase()
833+
if (availability === 'newly' && node.date) {
833834
throw new BrowserslistError(
834835
'Using newly available with a date is not supported, please use "widely available on YYYY-MM-DD" and add 30 months to the date you specified.'
835836
)
@@ -848,7 +849,7 @@ var QUERIES = {
848849
includeKaiOS: includeKaiOS,
849850
suppressWarnings: true
850851
})
851-
} else if (node.availability === 'newly') {
852+
} else if (availability === 'newly') {
852853
var future30months = new Date().setMonth(new Date().getMonth() + 30)
853854
baselineVersions = bbm.getCompatibleVersions({
854855
widelyAvailableOnDate: future30months,

test/baseline.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,16 @@ test('Throws an error when "newly available on YYYY-MM-DD" is used', () => {
116116
}, /Using newly available with a date is not supported/)
117117
})
118118

119+
// Test case insensitivity
120+
test('Treats "newly available" as case insensitive', () => {
121+
equal(
122+
browserslist('BASELINE NEWLY AVAILABLE'),
123+
browserslistBaselineNewly
124+
)
125+
equal(
126+
browserslist('baseline NEWLY available'),
127+
browserslistBaselineNewly
128+
)
129+
})
130+
119131
test.run()

0 commit comments

Comments
 (0)