Skip to content

Commit

Permalink
remove commas in between numbers like backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Caius-Bonus committed Oct 20, 2023
1 parent e1d61f0 commit f7b311c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/common/string/slugify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const slugify = (value: string, delimiter = "_") => {
.toString()
.toLowerCase()
.replace(p, (c) => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/(?<=\d),(?=\d)/g, "") // Remove Commas between numbers
.replace(/[^\w]+/g, delimiter) // Replace all non-word characters
.replace(new RegExp(`(${delimiter})\\1+`, "g"), "$1") // Replace multiple delimiters with single delimiter
.replace(new RegExp(`^${delimiter}+`), "") // Trim delimiter from start of text
Expand Down
1 change: 1 addition & 0 deletions test/common/string/slugify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe("slugify", () => {
assert.strictEqual(slugify("1`-=~!@#$%^&*()_+[];',./{}:\"<>?\\|aA"), "1_aa");
assert.strictEqual(slugify("abc-DEF"), "abc_def");
assert.strictEqual(slugify("abc_DEF"), "abc_def");
assert.strictEqual(slugify("1,1"), "11");
assert.strictEqual(slugify("abc å DEF"), "abc_a_def");
assert.strictEqual(slugify("abc:DEF"), "abc_def");
assert.strictEqual(slugify("abc&DEF"), "abc_and_def");
Expand Down

0 comments on commit f7b311c

Please sign in to comment.