From 806e0890514c9d5638329c967ba6e0ddb42254aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20J=C3=A4genstedt?= Date: Thu, 11 Jul 2024 14:22:29 +0200 Subject: [PATCH] Ensure spec draft features have valid identifiers --- scripts/update-drafts.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/update-drafts.ts b/scripts/update-drafts.ts index b3a38762df1..8908700ce20 100644 --- a/scripts/update-drafts.ts +++ b/scripts/update-drafts.ts @@ -32,6 +32,13 @@ function normalize(page: string) { return String(url); } +function formatIdentifier(s: string): string { + return s + .toLowerCase() + .split(/[^a-z0-9-]+/) + .join("-"); +} + async function main() { const compat = new Compat(); @@ -97,7 +104,7 @@ async function main() { } // Write out draft feature per spec. - const id = spec.shortname; + const id = formatIdentifier(spec.shortname); const feature = new Document({ draft_date: new Date().toISOString().substring(0, 10),