Skip to content

Commit 41bdcb8

Browse files
Techn1xstefanpenner
authored andcommitted
More test fixes
1 parent 5516206 commit 41bdcb8

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

app/helpers/app-version.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@ export function makeHelper(version) {
1616
hash.versionOnly = hash.versionOnly || hash.hideSha;
1717
hash.shaOnly = hash.shaOnly || hash.hideVersion;
1818

19+
let match = null;
20+
1921
if (hash.versionOnly) {
2022
if (hash.showExtended) {
21-
return version.match(versionExtendedRegExp)[0]; // 1.0.0-alpha.1
23+
match = version.match(versionExtendedRegExp); // 1.0.0-alpha.1
2224
} else {
23-
return version.match(versionRegExp)[0]; // 1.0.0
25+
match = version.match(versionRegExp); // 1.0.0
2426
}
2527
}
2628

2729
if (hash.shaOnly) {
28-
return version.match(shaRegExp)[0]; // 4jds75hf
30+
match = version.match(shaRegExp); // 4jds75hf
2931
}
3032

31-
return version;
33+
return match?match[0]:version;
3234
};
3335
}
3436

tests/unit/utils/regexp-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ test('version reg ex matches expected strings', function(assert) {
1515
test('version extended reg ex matches expected strings', function(assert) {
1616
assert.expect(6);
1717

18-
assert.ok('2.0.1-alpha'.match(versionRegExp), 'Matches expected pattern.');
19-
assert.ok('2.20.1-alpha.15'.match(versionRegExp), 'Matches expected pattern.');
20-
assert.ok(!'1.1.1-alpha.'.match(versionRegExp), 'Does not match hanging period.');
21-
assert.ok(!'1.1.1-alpha.abc'.match(versionRegExp), 'Does not match letters after extended tag period.');
22-
assert.ok(!'a.b.c-alpha.15'.match(versionRegExp), 'Does not match letters.');
23-
assert.ok(!'git12sha'.match(versionRegExp), 'Does not match sha.');
18+
assert.ok('2.0.1-alpha'.match(versionExtendedRegExp), 'Matches expected pattern.');
19+
assert.ok('2.20.1-alpha.15'.match(versionExtendedRegExp), 'Matches expected pattern.');
20+
assert.ok(!'1.1.1-alpha.'.match(versionExtendedRegExp), 'Does not match hanging period.');
21+
assert.ok(!'1.1.1-alpha.abc'.match(versionExtendedRegExp), 'Does not match letters after extended tag period.');
22+
assert.ok(!'a.b.c-alpha.15'.match(versionExtendedRegExp), 'Does not match letters.');
23+
assert.ok(!'git12sha'.match(versionExtendedRegExp), 'Does not match sha.');
2424
});
2525

2626
test('git sha reg ex matches expected strings', function(assert) {

0 commit comments

Comments
 (0)