/** * URL-safe slug generator for ride names. * * Used as a secondary key on the `rides` table — the primary key is * (park_id, qt_ride_id) so renames don't lose history. The slug is just * for pretty URLs. * * Steps: * 1. NFD-normalize to split accented letters into base + combining mark * 2. Strip combining marks (diacritics, U+0300–U+036F) * 3. Strip trademark symbols * 4. Lowercase * 5. Replace any non-alphanumeric run with a single hyphen * 6. Trim leading/trailing hyphens * * Examples: * "X²" → "x" * "Lex Luthor: Drop of Doom" → "lex-luthor-drop-of-doom" * "Catwoman's Whip" → "catwoman-s-whip" * "Façade" → "facade" * "Batman™ The Ride" → "batman-the-ride" */ export function slugifyRideName(name: string): string { return name .normalize("NFD") .replace(/[̀-ͯ]/g, "") .replace(/[™®©]/g, "") .toLowerCase() .replace(/[^a-z0-9]+/g, "-") .replace(/^-+|-+$/g, ""); }