fix(web): open off-site links in a new tab - #3102
Closed
hmseeb wants to merge 1 commit into
Closed
Conversation
Markdown-rendered links (README, file previews, join-policy documents) navigated the current tab, pulling readers out of the app. Route all three through a shared Markdown component that adds target=_blank + rel=noopener noreferrer for cross-origin http(s) links only. Same-origin paths, in-page anchors, and custom schemes (buzz://) keep navigating in place — a new tab for a deep link just leaves an empty one behind. Signed-off-by: hmseeb <74695355+hmseeb@users.noreply.github.com>
hmseeb
force-pushed
the
external-links-new-tab
branch
from
July 27, 2026 09:39
efdb3ec to
0ee1f5c
Compare
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.
Problem
In the web client, links inside markdown-rendered content navigate the current
tab. Click a link in a repo's README, a previewed
.mdfile, or the Terms /Privacy documents on the invite page, and you're pulled out of Buzz entirely —
losing the repo you were browsing or, worse, the invite you were mid-way
through accepting.
Hand-written anchors already got this right (
View on web,Download it now).Markdown was the gap, and it's the surface most likely to contain arbitrary
third-party links.
Fix
A shared
Markdowncomponent (web/src/shared/ui/markdown.tsx) that addstarget="_blank"+rel="noopener noreferrer"to cross-originhttp(s)linksonly. The three existing call sites now use it instead of each configuring
react-markdownthemselves, which also de-duplicates theremarkGfmwiring.Deliberately left navigating in place:
buzz://deep links behind Open in Buzz andAccept invite in Buzz. Opening those in a new tab hands off to the desktop
app and strands an empty tab behind it.
No new dependency —
rehype-external-linkswould do this, but it isn't worth apackage for an eight-line predicate.
Test
web/tests/e2e/smoke.spec.tsgains a case that serves a join policy whoseterms markdown contains an off-site link, an in-app path, and an in-page
anchor, then asserts only the first opens in a new tab. Confirmed failing
before the fix (
Expected "_blank", Received ""), passing after.Full web smoke suite: 7/7 pass.
pnpm checkandpnpm typecheckclean.