Skip to content

discover: support hyperlinks and newlines in protocol descriptions (port to v5.47.0) - #2989

Merged
CassioMG merged 1 commit into
emergency-releasefrom
cg-port-pr-2985
Aug 31, 2026
Merged

discover: support hyperlinks and newlines in protocol descriptions (port to v5.47.0)#2989
CassioMG merged 1 commit into
emergency-releasefrom
cg-port-pr-2985

Conversation

@CassioMG

Copy link
Copy Markdown
Contributor

Port #2985 to the emergency-release branch so we can release it on 5.47.0 independently of other bigger changes present on master branch (e.g. balances-v2 migration).

…2985)

* discover: support hyperlinks and newlines in protocol descriptions

Adds a LinkifiedText component that turns markdown-style
[text](https://...) links and bare https:// URLs in a protocol's
description into clickable links, restricted to https to match the
existing isSafeHttpsUrl convention used for protocol.websiteUrl. Also
preserves embedded newlines via white-space: pre-line, which the
description text previously collapsed.

* discover: fix link parsing for balanced parens, restore link underline

Addresses Copilot review feedback on #2985:

- parseLinkedText previously excluded all parentheses from a URL's
  character class, truncating URLs that legitimately contain them
  (e.g. Wikipedia-style https://.../Function_(mathematics)), and for
  the markdown form the first ")" inside the URL was mistaken for the
  link's closing paren. Replaced the regex-based matcher with a small
  scanner that tracks paren depth so balanced parens stay part of the
  URL, and only an unmatched ")" ends it. Added regression tests for
  both the bare-URL and markdown-link forms.
- ProtocolDetailsPanel's global stylesheet resets all <a> underlines,
  so the description's links were distinguished from surrounding text
  by color alone. Restored text-decoration: underline on them so the
  link cue doesn't depend on color perception.

* discover: fix nested-bracket and label-URL parsing bugs

Addresses further review feedback on #2985:

- Copilot: a markdown label containing its own https:// URL (e.g.
  [https://a.example](https://b.example)) was mishandled because the
  parser scanned for bare https:// occurrences first, matching the
  label's URL before considering the markdown link around it.
- aristidesstaffieri: a stray, unmatched "[" before a real markdown
  link could swallow the real link into its own (invalid) label, since
  the backward-scanning opener regex always matched from the leftmost
  "[" rather than the nearest one.

Replaced the backward-scanning approach with a forward scanner that
looks for the next "[" or bare "https://" (whichever comes first) and
only commits to a markdown link once a complete, valid
[label](https://...) is found starting there; an incomplete/invalid
"[" is left as literal text and scanning resumes just past it. This
also incidentally required tightening the URL boundary characters to
include quotes, since a bare URL inside quotes was absorbing the
closing quote. Added regression tests for all three cases.

* discover: reject malformed URLs, keep brackets in markdown destinations

Addresses further Copilot feedback on #2985:

- A candidate was only checked against the "https://" text prefix, so
  malformed values like bare "https://" or "https://?query" (no host)
  were still emitted as clickable links, even though the existing
  isSafeHttpsUrl guard in Discover/index.tsx would reject them.
  Validate every candidate with `new URL(...)` and require the
  "https:" protocol before treating it as a link; reject candidates
  are left as plain text (the original substring, not `url.href`,
  is still used for display/navigation, since the WHATWG URL parser
  normalizes some inputs like adding a trailing slash to a bare
  origin).
- The URL boundary excluded square brackets universally, which broke
  markdown-link destinations containing the common `?tag[]=value`
  query syntax: the parse failed and the same target was then emitted
  as a truncated bare link pointing at the wrong address. Brackets are
  now only excluded from a *bare* URL's boundary (to avoid ambiguity
  with an immediately following markdown link) - a markdown
  destination's balanced closing paren is enough to bound it on its
  own.

Added regression tests for both.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings August 31, 2026 21:44
@CassioMG CassioMG changed the title discover: support hyperlinks and newlines in protocol descriptions (emergency-release) discover: support hyperlinks and newlines in protocol descriptions (port to v5.47.0) Aug 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Preview build is ready: https://github.com/stellar/freighter/releases/tag/untagged-45cad153afa865ce568f (SDF collaborators only — install instructions in the release description)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports hyperlink and newline support for Discover protocol descriptions to the emergency-release branch.

Changes:

  • Adds safe HTTPS link parsing and rendering.
  • Preserves description newlines and styles links accessibly.
  • Adds parser tests and documents supported syntax.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
@shared/api/types/types.ts Documents description syntax.
extension/src/popup/basics/LinkifiedText/index.tsx Renders parsed links.
extension/src/popup/basics/LinkifiedText/parseLinkedText.ts Parses Markdown and bare URLs.
extension/src/popup/basics/LinkifiedText/__tests__/parseLinkedText.test.ts Tests parser behavior.
extension/src/popup/views/Discover/components/ProtocolDetailsPanel/index.tsx Uses linkified descriptions.
extension/src/popup/views/Discover/components/ProtocolDetailsPanel/styles.scss Preserves newlines and styles links.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread extension/src/popup/basics/LinkifiedText/parseLinkedText.ts
Comment thread extension/src/popup/basics/LinkifiedText/parseLinkedText.ts
@CassioMG
CassioMG merged commit bac61ff into emergency-release Aug 31, 2026
6 checks passed
@CassioMG
CassioMG deleted the cg-port-pr-2985 branch August 31, 2026 22:00
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.

3 participants