Skip to content

fix(textUtils): Emit Auto-link target/rel via Mdast - #794

Merged
Xavier-Charles merged 2 commits into
devfrom
fix/remark-regex-link-attributes
Jul 13, 2026
Merged

Xavier-Charles merged 2 commits into
devfrom
fix/remark-regex-link-attributes

Conversation

@Xavier-Charles

Copy link
Copy Markdown
Contributor

Problem

The remarkRegex plugin in textUtils.tsx attaches hProperties to the
link node's value field. mdast-util-to-hast (used by react-markdown) only
reads hProperties from a node's data field, so the properties were
silently dropped — every auto-linked URL lost its target="_blank" and
rel="noopener noreferrer" attributes.

This is both:

  • a security/UX regression — generated links no longer open in a new tab
    and lost the noopener protection, and
  • the cause of the failing remarkRegex() snapshot test.

The attributes were placed under value only to satisfy the
IParentWithLiteral interface (which required a value), so the type shape
was masking the real bug.

Fix

  • Move hProperties from value → data (the correct mdast field).
  • Relax IParentWithLiteral so link nodes aren't forced to carry value.
  • Remove the obsolete duplicate snapshot entry.

Verification

Check Result
textUtils.test.ts ✅ 4/4 pass (was failing)
Typecheck (frontend + ui-kit) ✅ clean
Lint (changed file) ✅ clean
Full unit suite 12 failed → was 13 (this fix), no regressions

The remaining 12 failures are pre-existing environmental issues (Web Share
API, ResizeObserver, redux store, firebase script loading) unrelated to this
change.

@Xavier-Charles
Xavier-Charles marked this pull request as draft July 13, 2026 16:08
@Xavier-Charles
Xavier-Charles marked this pull request as ready for review July 13, 2026 16:08
@Xavier-Charles
Xavier-Charles merged commit 378f67c into dev Jul 13, 2026
1 check passed
@Xavier-Charles
Xavier-Charles deleted the fix/remark-regex-link-attributes branch July 13, 2026 21: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.

2 participants