Skip to content

Commit

Permalink
fix: correctly expand catalog numbers when a string starts with numbers
Browse files Browse the repository at this point in the history
Fix #1518
  • Loading branch information
php-coder committed Aug 1, 2023
1 parent e60e9ed commit 593e754
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/frontend/src/utils/CatalogUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var CatalogUtils = {
return input;
}

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

Expand Down
8 changes: 8 additions & 0 deletions src/main/frontend/src/utils/CatalogUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ describe("CatalogUtils.expandNumbers()", function() {
expect(CatalogUtils.expandNumbers("1-3,5-6,8-9")).toEqual("1,2,3,5,6,8,9");
});

it("should return '989,1166,1167' for '989,1166-1167'", function() {
expect(CatalogUtils.expandNumbers("989,1166-1167")).toEqual("989,1166,1167");
});

it("should return '989,1166,1167' for '989,1166-1167'", function() {
expect(CatalogUtils.expandNumbers(" 989,1166-1167")).toEqual("989,1166,1167");
});

it("should return 'test 1-3' for 'test 1-3'", function() {
expect(CatalogUtils.expandNumbers("test 1-3")).toEqual("test 1-3");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class ResourceUrl {
public static final String STATIC_RESOURCES_URL = "https://stamps.filezz.ru";

// MUST be updated when any of our resources were modified
public static final String RESOURCES_VERSION = "v0.4.6.0";
public static final String RESOURCES_VERSION = "v0.4.6.1";

// CheckStyle: ignore LineLength for next 17 lines
private static final String CATALOG_UTILS_JS = "/public/js/" + RESOURCES_VERSION + "/utils/CatalogUtils.min.js";
Expand Down

0 comments on commit 593e754

Please sign in to comment.