Support Unicode capture slugs
This commit is contained in:
+5
-4
@@ -5,12 +5,13 @@ export function slugify(input: string, fallback = "chatgpt-share"): string {
|
||||
.normalize("NFKD")
|
||||
.replace(STOP_CHARS, "")
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
.replace(/[^\p{L}\p{N}]+/gu, "-")
|
||||
.replace(/^-+|-+$/g, "")
|
||||
.replace(/-{2,}/g, "-")
|
||||
.slice(0, 80);
|
||||
.replace(/-{2,}/g, "-");
|
||||
|
||||
return base || fallback;
|
||||
const truncated = Array.from(base).slice(0, 80).join("").replace(/-+$/g, "");
|
||||
|
||||
return truncated || fallback;
|
||||
}
|
||||
|
||||
export function displayTitleFromSlug(slug: string): string {
|
||||
|
||||
Reference in New Issue
Block a user