Skip to content

Commit

Permalink
fix(cli): reduce false positives from broken link checker (#5642)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Jan 17, 2025
1 parent 48a037e commit 4deeb7d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
4 changes: 4 additions & 0 deletions fern/pages/changelogs/cli/2025-01-17.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.50.6
**`(fix):`** The broken link checker is updated to reduce false positives.


8 changes: 8 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
- changelogEntry:
- summary: |
The broken link checker is updated to reduce false positives.
type: fix
irVersion: 55
version: 0.50.6


- changelogEntry:
- summary: |
The Fern CLI is updated to create the organization if it doesn't exist when `fern token` is called.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,15 @@ export async function checkIfPathnameExists({
// if the pathname starts with `/`, it must either be a slug or a file in the current workspace
if (pathname.startsWith("/")) {
// only check slugs if the file is expected to be a markdown file
if (markdown && pageSlugs.has(removeLeadingSlash(withRedirects(pathname, baseUrl, redirects)))) {
const redirectedPath = withRedirects(pathname, baseUrl, redirects);

if (markdown && pageSlugs.has(removeLeadingSlash(redirectedPath))) {
return true;
}

if (
await doesPathExist(
join(workspaceAbsoluteFilePath, RelativeFilePath.of(removeLeadingSlash(pathname))),
"file"
)
) {
const absolutePath = join(workspaceAbsoluteFilePath, RelativeFilePath.of(removeLeadingSlash(pathname)));

if (await doesPathExist(absolutePath, "file")) {
return true;
}

Expand All @@ -82,13 +81,11 @@ export async function checkIfPathnameExists({
}

// if that fails, we need to check if the path exists against all of the slugs for the current file

const brokenSlugs: string[] = [];
for (const slug of slugs) {
const url = new URL(`/${slug}`, wrapWithHttps(baseUrl.domain));
const targetSlug = withRedirects(new URL(pathname, url).pathname, baseUrl, redirects);

if (!pageSlugs.has(targetSlug)) {
if (!pageSlugs.has(removeLeadingSlash(targetSlug))) {
brokenSlugs.push(slug);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import chalk from "chalk";
import { randomUUID } from "crypto";

import { noop } from "@fern-api/core-utils";
import { DocsDefinitionResolver, filterOssWorkspaces } from "@fern-api/docs-resolver";
import { convertIrToApiDefinition } from "@fern-api/docs-resolver";
import { DocsDefinitionResolver, convertIrToApiDefinition } from "@fern-api/docs-resolver";
import { APIV1Read, ApiDefinition, FernNavigation } from "@fern-api/fdr-sdk";
import { AbsoluteFilePath, RelativeFilePath, join } from "@fern-api/fs-utils";
import { generateIntermediateRepresentation } from "@fern-api/ir-generator";
import { OSSWorkspace } from "@fern-api/lazy-fern-workspace";
import { createLogger } from "@fern-api/logger";
import { createMockTaskContext } from "@fern-api/task-context";

Expand Down

0 comments on commit 4deeb7d

Please sign in to comment.