feat: add slugify utility

This commit is contained in:
2026-03-26 11:54:42 -05:00
parent 86c1389d67
commit af2e48347f
2 changed files with 28 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import { describe, it, expect } from 'vitest';
import { slugify } from '$lib/slugify';
describe('slugify', () => {
it('converts to lowercase with hyphens', () => {
expect(slugify('Hello World')).toBe('hello-world');
});
it('removes special characters', () => {
expect(slugify("Buddy's Adventure!")).toBe('buddys-adventure');
});
it('collapses multiple hyphens', () => {
expect(slugify('foo bar---baz')).toBe('foo-bar-baz');
});
it('trims leading and trailing hyphens', () => {
expect(slugify(' hello ')).toBe('hello');
});
});