Skip to content

Commit 760dc8f

Browse files
louis-preclaude
andcommitted
chore: Remove unnecessary comments from redirect validator
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 263f868 commit 760dc8f

1 file changed

Lines changed: 0 additions & 10 deletions

File tree

codegen/validate-redirects.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,17 @@ const redirects: Redirect[] = Object.entries(gitbookConfig.redirects ?? {}).map(
1818
([source, target]) => ({ source, target }),
1919
)
2020

21-
// Check if a path resolves to a page as a file, URL slug, or directory index.
2221
function pageExists(fullPath: string): boolean {
23-
// Exact file match (e.g., quickstart.md) — must be a file, not a directory
2422
if (existsSync(fullPath) && statSync(fullPath).isFile()) return true
25-
// URL-style target without .md extension (e.g., api/devices → api/devices.md)
2623
if (!fullPath.endsWith('.md') && existsSync(fullPath + '.md')) return true
27-
// README.md targets resolve as directory URLs in GitBook, so check if the
28-
// parent path resolves as a page (e.g., foo/README.md → foo.md).
2924
if (fullPath.endsWith('/README.md')) {
3025
const parentPath = fullPath.slice(0, -'/README.md'.length)
3126
if (existsSync(parentPath + '.md')) return true
3227
}
3328
return false
3429
}
3530

36-
// Resolve a redirect target to check it points to a real page.
37-
// Targets may reference other site sections via URL prefix.
3831
function resolveTarget(target: string): boolean {
39-
// Try matching against site sections by URL prefix (most specific first).
40-
// The siteSections array is already ordered with more-specific prefixes first.
4132
for (const section of siteSections) {
4233
if (section.urlPrefix === '') continue
4334

@@ -48,7 +39,6 @@ function resolveTarget(target: string): boolean {
4839
}
4940
}
5041

51-
// Fall back to the default section (Guides, urlPrefix '')
5242
const guidesSection = siteSections.find((s) => s.urlPrefix === '')
5343
if (guidesSection == null) return false
5444

0 commit comments

Comments
 (0)