fix: local url DOCSTOOLS-6242#989
Merged
Merged
Conversation
|
Contributor
Summary
🎉 No failed tests in this run. Github Test Reporter by CTRF 💚 |
reazy015
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixed a regression that caused a false error
Unreachable link: "mailto:centru@datepersonale.md"when building.Cause
Earlier in this session,
url.parse()inpackages/transform/src/transform/plugins/links/index.tswas replaced with the new helperparseHreffrom@diplodoc/utils. The problem turned out to be not in the helper itself, but in the existing functionisLocalUrl, which was supposed to cut off external links (mailto:,tel:etc.) before callingparseHref/url.parse.Its regex
/^(?:[a-z]+:)?\/\//icatches onlyscheme://...`` and//host, but it **doesn't catch** "opaque" URI schemes without//, likemailto:foo@bar.md. Previously, this hole was masked by a side effect of legacyurl.parse(): formailto:centru@datepersonale.md, it parsedcentruasauth,datepersonale.mdashost, and leftpathnameasnull, and the code in theelse { 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 thePAGE_LINK_REGEXP, and the code attempted to resolve it as a document file, resulting in anUnreachable link`.Fix
In
packages/transform/src/transform/utils.ts,isLocalUrlreuses the existingisExternalHrefin the same file (the same logic as in theisExternalHref/isLocalUrlof theclipackage, which correctly catchesmailto:,tel:, and custom schemes regardless of the presence of//):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
packages/transform/test/links.test.ts: formailto:...mdandtel:...— both confirm that the link remains external and does not attempt to resolve as a file.npx tsc --noEmitinpackages/transform— clean.transformpackage: 971 passed | 1 skipped (was 969, +2 new).