mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 03:59: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);
|
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 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);
|
const result = utils.slugify(testString);
|
||||||
expect(result).toBe(expectedSlug);
|
expect(result).toBe(expectedSlug);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -499,11 +499,10 @@ export function formatSize(size: number | null | undefined) {
|
|||||||
|
|
||||||
function slugify(text: string) {
|
function slugify(text: string) {
|
||||||
return text
|
return text
|
||||||
.normalize("NFKD") // decompose accents
|
.normalize("NFC") // keep composed form, preserves accents
|
||||||
.replace(/\p{Mark}/gu, "") // remove diacritics cleanly
|
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.replace(/[^\p{Letter}\p{Number}]+/gu, "-") // keep Unicode letters/numbers
|
.replace(/[^\p{Letter}\p{Number}]+/gu, "-") // replace non-letter/number with "-"
|
||||||
.replace(/(^-|-$)+/g, ""); // trim leading/trailing dashes
|
.replace(/(^-|-$)+/g, ""); // trim dashes
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user