chore(share): improve slugification to strip diacritics cleanly

This commit is contained in:
Elian Doran
2025-10-23 14:26:15 +03:00
parent d2b6014b49
commit 0fa1c0f5c4
2 changed files with 32 additions and 1 deletions

View File

@@ -681,3 +681,33 @@ describe("#normalizeCustomHandlerPattern", () => {
});
});
});
describe("#slugify", () => {
it("should return a slugified string", () => {
const testString = "This is a Test String! With unicode & Special #Chars.";
const expectedSlug = "this-is-a-test-string-with-unicode-special-chars";
const result = utils.slugify(testString);
expect(result).toBe(expectedSlug);
});
it("supports CJK characters without alteration", () => {
const testString = "测试中文字符";
const expectedSlug = "测试中文字符";
const result = utils.slugify(testString);
expect(result).toBe(expectedSlug);
});
it("supports Cyrillic characters without alteration", () => {
const testString = "Тестирование кириллических символов";
const expectedSlug = "тестирование-кириллических-символов";
const result = utils.slugify(testString);
expect(result).toBe(expectedSlug);
});
it("removes diacritic marks from characters", () => {
const testString = "Café naïve façade jalapeño";
const expectedSlug = "cafe-naive-facade-jalapeno";
const result = utils.slugify(testString);
expect(result).toBe(expectedSlug);
});
});