Files
outline/shared/utils/slugify.ts
T
Tom Moor a004b24e83 chore: Upgrade slug from 5 to 11 (#14038)
* chore: Upgrade slug from 5 to 11

* Require Node 22.12+ for require(esm), test θ transliteration

* Polyfill String isWellFormed and toWellFormed for older browsers
2026-10-11 16:13:48 -04:00

18 lines
435 B
TypeScript

import slug from "slug";
slug.defaults.mode = "rfc3986";
/**
* Convert a string to a slug that can be used in a URL in kebab-case format,
* and remove periods.
*
* @param text The text to convert
* @returns The slugified text
*/
export default function slugify(text: string): string {
// slug throws on malformed strings, so replace unpaired surrogates first.
return slug(text.toWellFormed(), {
remove: /[.]/g,
});
}