Skip to content

Commit 84d9ccb

Browse files
committed
CatalogUtils.expandNumbers(): fix expanding of numbers with trailing spaces.
1 parent 3784c4f commit 84d9ccb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/javascript/CatalogUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var CatalogUtils = {
1010
return input;
1111
}
1212

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

src/test/javascript/CatlogUtilsSpec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,12 @@ describe("CatalogUtils.expandNumbers()", function() {
7272
expect(CatalogUtils.expandNumbers("854-856, 146")).toEqual("854,855,856,146");
7373
});
7474

75+
it("should return '4596,4597,4598' for ' 4596-8'", function() {
76+
expect(CatalogUtils.expandNumbers(" 4596-8")).toEqual("4596,4597,4598");
77+
});
78+
79+
it("should return '4596,4597,4598' for '4596-8 '", function() {
80+
expect(CatalogUtils.expandNumbers("4596-8 ")).toEqual("4596,4597,4598");
81+
});
82+
7583
});

0 commit comments

Comments
 (0)