From dd817d08c0a1715e5aae6ae4614b41b31949e66b Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 3 Jan 2025 16:43:51 +0100 Subject: [PATCH] fix(lint): support pages with multiple browser-compat keys --- lint/linter/test-mdn-urls.ts | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lint/linter/test-mdn-urls.ts b/lint/linter/test-mdn-urls.ts index aaa6a752ecbe2d..12aaa42b009735 100644 --- a/lint/linter/test-mdn-urls.ts +++ b/lint/linter/test-mdn-urls.ts @@ -29,26 +29,25 @@ const slugByPath = (() => { continue; } - const path = item.frontmatter['browser-compat']; - if (typeof path !== 'string') { - // Ignore pages with multiple keys. - continue; - } + const value = item.frontmatter['browser-compat']; + const paths = Array.isArray(value) ? value : [value]; const slug = item.frontmatter.slug; - const slugTail = slug.split('/').at(-1); - const pathTail = path.split('.').at(-1); + for (const path of paths) { + const slugTail = slug.split('/').at(-1); + const pathTail = path.split('.').at(-1); - if (!slugTail.includes(pathTail) && !pathTail?.includes(slugTail)) { - // Ignore unrelated pages/features. - continue; - } + if (!slugTail.includes(pathTail) && !pathTail?.includes(slugTail)) { + // Ignore unrelated pages/features. + continue; + } - if (!slugsByPath.has(path)) { - slugsByPath.set(path, []); + if (!slugsByPath.has(path)) { + slugsByPath.set(path, []); + } + slugsByPath.get(path)?.push(item.frontmatter.slug); } - slugsByPath.get(path)?.push(item.frontmatter.slug); } const slugByPath = new Map();