Skip to content

Commit

Permalink
decode hashes as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
Elchi3 committed Jul 27, 2024
1 parent 7116139 commit b0c0149
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lint/linter/test-spec-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ const getValidSpecURLs = async (): Promise<string[]> => {
`https://raw.githubusercontent.com/w3c/webref/main/ed/${id}`,
);
const idResponse = JSON.parse(await idFile.text());
specURLsWithFragments.push(...idResponse.ids);
specURLsWithFragments.push(
...idResponse.ids.map((id) => {
const url = new URL(id);
return url.origin + url.pathname + decodeURIComponent(url.hash);
}),
);
}),
);
return specURLsWithFragments;
Expand All @@ -108,16 +113,15 @@ const processData = (data: CompatStatement, logger: Logger): void => {

for (const specURL of featureSpecURLs) {
if (specURL.includes('#')) {
const hasSpec = validSpecURLsWithFragments.includes(encodeURI(specURL));
const hasSpec = validSpecURLsWithFragments.includes(specURL);

const alternateSpecURLs = validSpecHosts.filter(
(spec) => spec.url === specURL.split('#')[0],
);

const hasAlternateSpec = alternateSpecURLs.some((altSpecURL) => {
const specToLookup = encodeURI(
altSpecURL.alternateUrl + '#' + specURL.split('#')[1],
);
const specToLookup =
altSpecURL.alternateUrl + '#' + specURL.split('#')[1];
if (validSpecURLsWithFragments.includes(specToLookup)) {
return true;
}
Expand Down

0 comments on commit b0c0149

Please sign in to comment.