Skip to content

Commit

Permalink
fix spaces error
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Feb 4, 2024
1 parent eb75e47 commit e447484
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions apps/buildbox/widget/utils/stringUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@

const normalize = (text) =>
text
.replaceAll(/[- \.]/g, "_")
.replaceAll(/[^\w]+/g, "")
.replaceAll(/_+/g, "-")
.replace(/^-+/, "")
.replace(/-+$/, "")
// Convert to lowercase
.toLowerCase()
.trim("-");
// Replace spaces with dashes
.replace(/\s+/g, "-")
// Replace any non-alphanumeric characters (excluding dashes) with nothing
.replace(/[^a-z0-9-]/g, "")
// Replace multiple consecutive dashes with a single dash
.replace(/-+/g, "-")
// Trim dashes from the start and end of the string
.replace(/^-+|-+$/g, "");

return { normalize };
return { normalize };

0 comments on commit e447484

Please sign in to comment.