Skip to content

fix: local url DOCSTOOLS-6242#989

Merged
diplodoc-app[bot] merged 1 commit into
masterfrom
remove-node-url
Jul 15, 2026
Merged

fix: local url DOCSTOOLS-6242#989
diplodoc-app[bot] merged 1 commit into
masterfrom
remove-node-url

Conversation

@goldserg

@goldserg goldserg commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Fixed a regression that caused a false error Unreachable link: "mailto:centru@datepersonale.md" when building.

Cause

Earlier in this session, url.parse() in packages/transform/src/transform/plugins/links/index.ts was replaced with the new helper parseHref from @diplodoc/utils. The problem turned out to be not in the helper itself, but in the existing function isLocalUrl, which was supposed to cut off external links (mailto:, tel: etc.) before calling parseHref/url.parse.

Its regex /^(?:[a-z]+:)?\/\//i catches only scheme://...`` and //host, but it **doesn't catch** "opaque" URI schemes without //, like mailto:foo@bar.md. Previously, this hole was masked by a side effect of legacy url.parse(): for mailto:centru@datepersonale.md, it parsed centruasauth, datepersonale.mdashost, and left pathnameasnull, and the code in the else { return; }branch silently skipped such a link. The newparseHref(as well as the correct WHATWG approach) does not use auth/host heuristics for schemes without//and returns the entire string aftermailto:aspathname. Since the string ends with .md, it passed the PAGE_LINK_REGEXP, and the code attempted to resolve it as a document file, resulting in an Unreachable link`.

Fix

In packages/transform/src/transform/utils.ts, isLocalUrl reuses the existing isExternalHref in the same file (the same logic as in the isExternalHref/isLocalUrl of the cli package, which correctly catches mailto:, tel:, and custom schemes regardless of the presence of //):

export function isLocalUrl(url: string) {
    return !isExternalHref(url);
}

Now such links are cut off at the earliest stage — before the call to parseHref — and marked as external (target="_blank", rel="noreferrer noopener"), as it was previously intended for external protocols.

Checking

  • Added 2 regression tests in packages/transform/test/links.test.ts: for mailto:...md and tel:... — both confirm that the link remains external and does not attempt to resolve as a file.
  • npx tsc --noEmit in packages/transform — clean.
  • Full set of tests for the transform package: 971 passed | 1 skipped (was 969, +2 new).

@goldserg goldserg requested review from a team and diplodoc-bot as code owners July 15, 2026 10:40
@goldserg goldserg requested review from HelenVirtanen and kadymov and removed request for a team July 15, 2026 10:40
@sonarqubecloud

Copy link
Copy Markdown

@yc-ui-bot

Copy link
Copy Markdown
Contributor

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
189 169 0 20 0 2 1m 56s

🎉 No failed tests in this run.

Github Test Reporter by CTRF 💚

@diplodoc-app diplodoc-app Bot merged commit 6e9099d into master Jul 15, 2026
9 checks passed
@diplodoc-app diplodoc-app Bot deleted the remove-node-url branch July 15, 2026 14:34
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.

3 participants