Skip to content

fix(web): open off-site links in a new tab - #3102

Closed
hmseeb wants to merge 1 commit into
block:mainfrom
hmseeb:external-links-new-tab
Closed

fix(web): open off-site links in a new tab#3102
hmseeb wants to merge 1 commit into
block:mainfrom
hmseeb:external-links-new-tab

Conversation

@hmseeb

@hmseeb hmseeb commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Problem

In the web client, links inside markdown-rendered content navigate the current
tab. Click a link in a repo's README, a previewed .md file, 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 Markdown component (web/src/shared/ui/markdown.tsx) that adds
target="_blank" + rel="noopener noreferrer" to cross-origin http(s) links
only. The three existing call sites now use it instead of each configuring
react-markdown themselves, which also de-duplicates the remarkGfm wiring.

Deliberately left navigating in place:

  • Same-origin paths and in-page anchors — normal in-app navigation.
  • Custom schemes, notably the buzz:// deep links behind Open in Buzz and
    Accept 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-links would do this, but it isn't worth a
package for an eight-line predicate.

Test

web/tests/e2e/smoke.spec.ts gains a case that serves a join policy whose
terms 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 check and pnpm typecheck clean.

@hmseeb
hmseeb requested a review from a team as a code owner July 27, 2026 09:39
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
hmseeb force-pushed the external-links-new-tab branch from efdb3ec to 0ee1f5c Compare July 27, 2026 09:39
@hmseeb hmseeb closed this Jul 27, 2026
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.

1 participant