Skip to content

fix: treat mailto: links as fully qualified for target/rel options - #232

Open
TastyHeadphones wants to merge 1 commit into
microcosm-cc:mainfrom
TastyHeadphones:fix/mailto-fully-qualified-links
Open

TastyHeadphones wants to merge 1 commit into
microcosm-cc:mainfrom
TastyHeadphones:fix/mailto-fully-qualified-links

Conversation

@TastyHeadphones

Copy link
Copy Markdown

Summary

Fixes #231.

AddTargetBlankToFullyQualifiedLinks, RequireNoFollowOnFullyQualifiedLinks, and RequireNoReferrerOnFullyQualifiedLinks only treated a link as fully qualified when url.Parse(href).Host != "". Go parses mailto: URLs as opaque (Host == ""), so those options never applied to mailto links (webmail clients then navigate the current tab away).

Treat mailto: with a non-empty opaque part as fully qualified as well.

Test plan

  • Added TestMailtoFullyQualifiedLinks
  • go test -count=1 -run TestMailtoFullyQualifiedLinks .

AI disclosure

Drafted with Grok assistance; I reviewed the change against #231 and ran the new regression test.

Go parses mailto URLs as opaque (Host empty), so AddTargetBlank /
RequireNoFollow / RequireNoReferrer on fully-qualified links skipped
them (microcosm-cc#231). Count mailto with a non-empty opaque part as external.

Disclosure: drafted with Grok assistance; I reviewed and tested.
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.

AddTargetBlankToFullyQualifiedLinks ignore mailto: links

1 participant