Skip to content

Add support for opening external links in system browser#21

Merged
ptheofan merged 1 commit into
mainfrom
claude/external-links-system-browser-FNEu9
May 14, 2026
Merged

Add support for opening external links in system browser#21
ptheofan merged 1 commit into
mainfrom
claude/external-links-system-browser-FNEu9

Conversation

@ptheofan

Copy link
Copy Markdown
Owner

Summary

This PR adds functionality to handle external links (http, https, mailto) in the markdown viewer by opening them in the system's default browser or handler, rather than attempting to navigate within the application.

Key Changes

  • MarkdownViewer: Added setupLinkHandling() to intercept clicks on external links and open them via the system browser
  • MarkdownViewer: Added isExternalUrl() helper to identify external URLs by protocol (http, https, mailto)
  • MarkdownViewer: Enhanced context menu to show "Copy Link" and "Open in Default Browser" options for external links
  • ShellHandler: Implemented new OPEN_EXTERNAL IPC handler with protocol validation to prevent opening dangerous URLs (file://, javascript://, etc.)
  • API Types: Added openExternal() method to ShellAPI interface and corresponding IPC channel
  • Preload: Exposed shell.openExternal() to renderer process via electron API
  • Tests: Added comprehensive test coverage for the new OPEN_EXTERNAL handler, including validation of allowed protocols and rejection of invalid URLs

Implementation Details

  • External link detection uses URL parsing with try-catch to safely validate URLs
  • Protocol whitelist (http:, https:, mailto:) is enforced at the main process level for security
  • Context menu for links provides both copy and open actions for user convenience
  • All external link operations are properly prevented from default browser navigation behavior

https://claude.ai/code/session_01A83A3GHjE9aQz4C6zhwar9

Clicking an http/https/mailto link in rendered markdown now opens it in
the default system browser instead of navigating the app window.
Right-clicking such a link shows a context menu with options to copy the
link or open it in the browser. URL protocols are validated in the main
process before handing off to shell.openExternal.

Closes #16

https://claude.ai/code/session_01A83A3GHjE9aQz4C6zhwar9
@ptheofan ptheofan merged commit 65a7c03 into main May 14, 2026
4 checks passed
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.

2 participants