Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions scripts/wiki-link-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ export function buildSlugAliases(slugMap) {
if (key && !aliases.has(key)) aliases.set(key, slug);
}
}
// Infobox "Related concept" values are free text, not always the exact article
// title: an author can write a hyphenated compound like "Commit-reveal" where
// the target article's title is the space-separated "Commit Reveal" (slug
// commit_reveal). slugify() only turns spaces into underscores, so the
// hyphenated form never matches any key generated above, and the edge is
// silently dropped. For every alias key that contains a hyphen or an
// underscore, also register the opposite form (first key registered for a
// given variant wins, matching the never-overwrite rule above), so either
// spelling of a compound term resolves to the same article.
for (const [key, slug] of [...aliases]) {
if (!key.includes('-') && !key.includes('_')) continue;
const swapped = key.includes('-') ? key.replace(/-/g, '_') : key.replace(/_/g, '-');
if (swapped !== key && !aliases.has(swapped)) aliases.set(swapped, slug);
}
return aliases;
}

Expand Down
Loading