mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 20:19:05 +01:00
chore(share): keep diacritics in slug instead of stripping them in
This commit is contained in:
parent
0fa1c0f5c4
commit
aae90ede19
@ -704,9 +704,10 @@ describe("#slugify", () => {
|
||||
expect(result).toBe(expectedSlug);
|
||||
});
|
||||
|
||||
it("removes diacritic marks from characters", () => {
|
||||
// preserves diacritic marks
|
||||
it("preserves diacritic marks", () => {
|
||||
const testString = "Café naïve façade jalapeño";
|
||||
const expectedSlug = "cafe-naive-facade-jalapeno";
|
||||
const expectedSlug = "café-naïve-façade-jalapeño";
|
||||
const result = utils.slugify(testString);
|
||||
expect(result).toBe(expectedSlug);
|
||||
});
|
||||
|
||||
@ -499,11 +499,10 @@ export function formatSize(size: number | null | undefined) {
|
||||
|
||||
function slugify(text: string) {
|
||||
return text
|
||||
.normalize("NFKD") // decompose accents
|
||||
.replace(/\p{Mark}/gu, "") // remove diacritics cleanly
|
||||
.normalize("NFC") // keep composed form, preserves accents
|
||||
.toLowerCase()
|
||||
.replace(/[^\p{Letter}\p{Number}]+/gu, "-") // keep Unicode letters/numbers
|
||||
.replace(/(^-|-$)+/g, ""); // trim leading/trailing dashes
|
||||
.replace(/[^\p{Letter}\p{Number}]+/gu, "-") // replace non-letter/number with "-"
|
||||
.replace(/(^-|-$)+/g, ""); // trim dashes
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user