Skip to content

Commit

Permalink
tsignore
Browse files Browse the repository at this point in the history
  • Loading branch information
ZYJLiu committed Aug 1, 2024
1 parent 56ecba1 commit 5782207
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/utils/contentApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ export default class ContentApi {

// we remove any special characters from the end of the label
// to make it look cleaner in the UI
// @ts-ignore
label = label.replace(/[^\p{L}\p{N}]+$/u, "");

// if (!duplicator.has(label)) {
Expand Down Expand Up @@ -380,18 +381,21 @@ export default class ContentApi {
*/
static slugify(url: string): string {
try {
return url
.toString()
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase()
.trim()
.replace(/\s+/g, "-")
.replace(/\./g, "")
.replace(/[^\p{L}\p{N}]+/gu, "-")
.replace(/^-/g, "")
.replace(/-$/g, "")
.replace(/--+/g, "-");
return (
url
.toString()
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase()
.trim()
.replace(/\s+/g, "-")
.replace(/\./g, "")
// @ts-ignore
.replace(/[^\p{L}\p{N}]+/gu, "-")
.replace(/^-/g, "")
.replace(/-$/g, "")
.replace(/--+/g, "-")
);
} catch (err) {
console.error("[slugify error]", err);
return "#err";
Expand Down

0 comments on commit 5782207

Please sign in to comment.