fix: treat non-http url protocols as external links#523
Merged
Conversation
Non-http URL schemes (mailto:, tel:, sms:, skype:, geo:, file:, etc.) were treated as relative doc paths, so a link like mailto:[email protected] was rendered through NextLink and prefixed with the current doc path, producing a broken /owner/repo/mailto:... route that 404s. isExternalLink now also matches an RFC-3986 URI scheme prefix, so any scheme-based link is rendered as a bare anchor. Non-http external links drop target="_blank"/rel="noopener", which only make sense for http(s). Fixes #454
Ehesp
marked this pull request as ready for review
July 8, 2026 18:39
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.
Requested by Elliot Hesp · Slack thread
Fixes #454
Summary
Non-http URL schemes were treated as relative doc paths instead of external links.
Before: A
mailto:[email protected]link (ortel:,sms:,skype:,geo:,file:, etc.) was rendered throughNextLink, which prepended the current doc path. Clicking it navigated to something likehttps://docs.page/owner/repo/mailto:[email protected], which 404s. The mail client never opened.After: The same link is recognised as external and rendered as a bare anchor, so the browser hands it off to the right handler — a
mailto:link opens the mail client,tel:starts a call, etc.How:
isExternalLinkinapp/src/lib/docs-links.tskeeps its existinghttp:///https://///checks and additionally matches an RFC-3986 URI scheme prefix via/^[a-z][a-z0-9+.-]*:/i. Internal doc hrefs are path-like (/foo,foo/bar,#anchor,?query) and never start with a scheme, so there are no false positives. This is future-proof and covers every scheme without enumerating them.app/src/components/doc-link.tsxnow renders non-http external links as a plain<a href>withouttarget="_blank"/rel="noopener", which only make sense for http(s) navigation.Scope
app/(hosted site, MCP, Ask AI)packages/cli/packages/mdx-bundler/docs/(product documentation)Type of change
Test plan
bun test app/src/lib/docs-links.test.ts→ 3 pass / 0 failbun test app/src/lib/→ 32 pass / 0 fail (no regressions)bunx @biomejs/biome checkon changed files → cleanbunx tsc --noEmit -p app/tsconfig.json→ no errors in changed files (only pre-existing image-asset module imports remain)bun run checkpasses locally (changed files)Tested locally (
bun dev, CLI command, or other relevant command)Updated
docs/(if user-facing)Verified on a docs.page URL or local preview (if rendering/routing changed)
Preview check once the Railway deploy is up: open a doc containing a
mailto:/tel:link ondocspage-docspage-pr-<N>.up.railway.appat a path like/invertase/docs.page/<somepath>and confirm the link opens the mail client / dialer instead of 404ing.Notes for reviewers
Added
app/src/lib/docs-links.test.ts(bun:test, matching siblingdocs-nav.test.ts). No other callers ofisExternalLinkwere changed — the new behaviour is strictly more correct for all of them (scheme links are external everywhere). Thedoc-link.tsxchange is a minimal branch split; http(s) links still open in a new tab as before.🤖 Generated with Claude Code
https://claude.ai/code/session_01891AY181bEZxpW4iwXuMTp
Generated by Claude Code