Skip to content

Commit 48389d0

Browse files
committed
CatalogUtils.expandNumbers(): expand numbers that are separated by slash.
1 parent 84d9ccb commit 48389d0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/main/javascript/CatalogUtils.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ var CatalogUtils = {
66
return input;
77
}
88

9-
if (input.indexOf('-') < 0) {
9+
if (input.indexOf('-') < 0 && input.indexOf('/') < 0) {
1010
return input;
1111
}
1212

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

@@ -27,7 +27,7 @@ var CatalogUtils = {
2727

2828
/** @private */
2929
expandRange: function(range) {
30-
var parts = range.split('-');
30+
var parts = range.split(/[-\/]/);
3131
if (parts.length != 2) {
3232
return range;
3333
}

src/test/javascript/CatlogUtilsSpec.js

+8
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,12 @@ describe("CatalogUtils.expandNumbers()", function() {
8080
expect(CatalogUtils.expandNumbers("4596-8 ")).toEqual("4596,4597,4598");
8181
});
8282

83+
it("should return '1,2,3' for '1/3'", function() {
84+
expect(CatalogUtils.expandNumbers("1/3")).toEqual("1,2,3");
85+
});
86+
87+
it("should return '1,2,3,4,5,6' for '1/3, 4-6'", function() {
88+
expect(CatalogUtils.expandNumbers("1/3, 4-6")).toEqual("1,2,3,4,5,6");
89+
});
90+
8391
});

0 commit comments

Comments
 (0)