Skip to content

fix: validate empty-text links and /assets/ links to the project root - #256

Merged
mgks merged 1 commit into
docmd-io:mainfrom
Aryan007-dev:fix/validate-links
Oct 14, 2026
Merged

mgks merged 1 commit into
docmd-io:mainfrom
Aryan007-dev:fix/validate-links

Conversation

@Aryan007-dev

Copy link
Copy Markdown
Contributor

Description

Fixes #251
Fixes #250

Two bugs in validateLinks (packages/core/src/commands/mcp.ts), used by both docmd validate and the MCP validate_docs tool.

#251: links with empty text were never checked. The link regex was /\[([^\]]+)\]\(([^)]+)\)/, which requires at least one character between the brackets. [](./missing.jpg) therefore never matched, and validate reported success. The text part is now matched with *.

#250: /assets/... links were reported as broken. Absolute links were resolved only under the docs directory, e.g. docs/assets/images/screenshot.jpg. The build copies the project-root assets/ directory to /assets/ in the site (engine/assets.ts), so a link to a file in assets/ is valid. A /assets/... link is now also accepted when the file exists under the project-root assets/. Docs-relative resolution is unchanged and still checked first, and a missing file is still reported.

Type of change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Tests

I added four cases to tests/cli-contracts/validate-workspace.test.js, using the same pattern as the existing M-1 checks:

  • #251: a broken link with empty text exits 1. Fails before the fix.
  • #251: a valid link with empty text exits 0.
  • #250: a /assets/... link to a file in the project-root assets/ exits 0. Fails before the fix.
  • #250: a /assets/... link to a missing file still exits 1.

pnpm verify passes (node tests/runner.js: 851 passed, 0 failed across 25 files). eslint reports no new warnings for mcp.ts (25 before, 25 after).

Not covered: workspace builds copy the shared assets/ into each project's output too. I only checked the single-project docmd validate path, which is what both issues report.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

validateLinks required at least one character of link text, so links like [](./image.jpg) were never checked (docmd-io#251). Absolute /assets/... links were only resolved under docs/, although the build copies the project-root assets/ directory to /assets/, so valid links were reported as broken (docmd-io#250).

Fixes docmd-io#251
Fixes docmd-io#250
@mgks

mgks commented Oct 14, 2026

Copy link
Copy Markdown
Member

Thank you @Aryan007-dev for the thorough fix and the test coverage! 🐛 Both bugs are now resolved — the empty alt-text regex and the /assets/ path resolution. 4 new contract tests confirm both happy and sad paths. Included in v0.9.8. Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: validate ignore images without alt description [Bug]: validate report non broken links as broken

2 participants