Skip to content

Commit

Permalink
Made more robust slug generator
Browse files Browse the repository at this point in the history
  • Loading branch information
albiinb committed Dec 8, 2024
1 parent 006d7dd commit 80e6fc0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion public/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,18 @@ function getLabelPrefix(labels) {
return "";
}

function generateSlug(name) {
return name
.toLowerCase()
.replace(/[^a-z0-9\s-]/g, "")
.replace(/\s+/g, "-")
.replace(/-+/g, "-")
.trim();
}

function formatText(boardAbbreviation, card) {
const cardShortUrl = card.idShort;
const cardSlug = card.name.toLowerCase().replace(/ /g, "-");
const cardSlug = generateSlug(card.name);
const labelPrefix = getLabelPrefix(card.labels);
return `${labelPrefix}${boardAbbreviation}-${cardShortUrl}-${cardSlug}`;
}
Expand Down

0 comments on commit 80e6fc0

Please sign in to comment.