Skip to content

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

Open
Xavier-Charles wants to merge 1 commit into
devfrom
fix/remark-regex-link-attributes
Open

fix(textUtils): Emit Auto-link target/rel via Mdast #794
Xavier-Charles wants to merge 1 commit 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 valuedata (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.

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