Skip to content

fix(dropdown): improve external link detection#49

Open
msmps wants to merge 1 commit intocloudflare:mainfrom
msmps:fix/dropdown-external-link-detection
Open

fix(dropdown): improve external link detection#49
msmps wants to merge 1 commit intocloudflare:mainfrom
msmps:fix/dropdown-external-link-detection

Conversation

@msmps
Copy link

@msmps msmps commented Feb 8, 2026

Description

  • Fix external link detection in Dropdown to also check for http:// and // (protocol-relative URLs)
  • Previously only https:// links opened in a new tab

Problem

The DropdownMenuItem component's external link detection only checked for https://:

const isExternal = href.startsWith("https://");

This meant http:// links and protocol-relative URLs (//example.com) were incorrectly treated as internal links and routed through LinkComponent instead of opening in a new tab.

Solution

Use a regex to match all external URL patterns:

const isExternal = /^(https?:)?\/\//.test(href);
Pattern Matches
https://example.com External
http://example.com External
//example.com External
/dashboard Internal

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