Skip to content

Commit 6eca1cf

Browse files
committed
CatalogUtils.expandNumbers(): fix expanding of numbers with space character(s).
1 parent 6307f65 commit 6eca1cf

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/javascript/CatalogUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ var CatalogUtils = {
1010
return input;
1111
}
1212

13-
if (! /^[0-9]+-[0-9]+(,[0-9]+(-[0-9]+)?)*$/.test(input)) {
13+
if (! /^[0-9]+-[0-9]+(,[ ]*[0-9]+(-[0-9]+)?)*$/.test(input)) {
1414
return input;
1515
}
1616

17-
var ranges = input.split(','),
17+
var ranges = input.replace(' ', '').split(','),
1818
result = [];
1919
// TODO: use jQuery.each() + jQuery.map()
2020
for (var i = 0; i < ranges.length; i++) {

src/test/javascript/CatlogUtilsSpec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,8 @@ describe("CatalogUtils.expandNumbers()", function() {
6868
expect(CatalogUtils.expandNumbers("09-5")).toEqual("09-5");
6969
});
7070

71+
it("should return '854,855,856,146' for '854-856, 146'", function() {
72+
expect(CatalogUtils.expandNumbers("854-856, 146")).toEqual("854,855,856,146");
73+
});
74+
7175
});

0 commit comments

Comments
 (0)