Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: broken links in link checker #2981

Merged
merged 1 commit into from
Sep 23, 2024
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: 9 additions & 5 deletions .github/actions/validate-docs-links/src/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,21 @@ async function prepareDocumentMapEntry(

// Checks if the links point to existing documents
function validateInternalLink(errors: Errors, href: string): void {
// /docs/api/example#heading -> ["api/example", "heading""]
const [link, hash] = href.split('#')
// Split the href into link and hash
// href could be: /reference/api/settings?utm_campaign=...#hash
const [linkWithQueryAndHash, hash] = href.split('#')

// Remove query parameters from the link
const linkWithQuery = linkWithQueryAndHash
const link = linkWithQuery.split('?')[0]

if (EXCLUDED_PATHS.includes(link)) return

if(link.startsWith('/assets')) return
if (link.startsWith('/assets')) return

// check if doc page exists
// Check if doc page exists
const foundPage = documentMap.get(link.replace(/^\/+/, ''))


if (!foundPage) {
errors.link.push(href)
} else if (hash && !EXCLUDED_HASHES.includes(hash)) {
Expand Down