All files / string slugify.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16                          5x    
import { kebabCase } from './kebab-case';
import { removeDiacritics } from './remove-diacritics';
 
/**
 * Turns a text into a URL- and id-friendly slug: accents removed, lower-case words joined with `-`.
 *
 * @param input - The text, such as a title or a label.
 * @returns The slug; `''` when the text has no letter or digit.
 * @example
 * slugify('Salle des machines — Été 2026'); // 'salle-des-machines-ete-2026'
 * slugify('  Hello, World!  '); // 'hello-world'
 */
export function slugify(input: string): string {
  return kebabCase(removeDiacritics(input));
}