Skip to content

Commit 1205f82

Browse files
authored
Force setEdition / has to normalize (by lowercasing) (#3)
Force setEdition / has to normalize (by lowercasing)
2 parents aac9744 + 17c4b93 commit 1205f82

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

index.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@param {string} editionName the Edition name that your application is authored in
77
*/
88
function setEdition(editionName) {
9-
process.env.EMBER_EDITION = editionName;
9+
process.env.EMBER_EDITION = editionName.toLowerCase();
1010
}
1111

1212
/**
@@ -38,7 +38,9 @@ function _getEdition() {
3838
}
3939
}
4040

41-
return edition;
41+
if (edition) {
42+
return edition.toLowerCase();
43+
}
4244
}
4345

4446
/**
@@ -51,7 +53,8 @@ function _getEdition() {
5153
5254
@param {string} requestedEditionName the Edition name that the application/addon is requesting
5355
*/
54-
function has(requestedEditionName) {
56+
function has(_requestedEditionName) {
57+
let requestedEditionName = _requestedEditionName.toLowerCase();
5558
let edition = _getEdition();
5659

5760
if (requestedEditionName === 'classic') {

test.js

+13
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ QUnit.module('@ember/edition-utils', function(hooks) {
2424

2525
assert.strictEqual(getEdition(), 'octane');
2626
});
27+
28+
test('normalizes the edition name that is passed in (lowercasing)', function(assert) {
29+
setEdition('OCTANE');
30+
31+
assert.strictEqual(getEdition(), 'octane');
32+
});
2733
});
2834

2935
QUnit.module('has', function() {
@@ -37,6 +43,13 @@ QUnit.module('@ember/edition-utils', function(hooks) {
3743
assert.ok(has('octane'));
3844
});
3945

46+
test('should match case insensitively', function(assert) {
47+
setEdition('octane');
48+
49+
assert.ok(has('OCTANE'));
50+
});
51+
52+
4053
test('should not "have" octane, when edition is classic', function(assert) {
4154
setEdition('classic');
4255

0 commit comments

Comments
 (0)