Skip to content

Use href of links instead of node.textContent for link previews #3871

@mejo-

Description

@mejo-

Describe the bug
Currently we use node.textContent to determine whether a paragraph is a link that warrants a link preview. Instead, we should check whether the paragraph has a link mark and use its href.

Reasons for this change would be:

  • We would make sure to always show the preview of the link target, not of the description text. Both may differ, which has security implications.
  • Links with a custom description would get a link preview as well.
  • Apparently url-encoded spaces in textContent of links get decoded when transformed to markdown. Spaces are not regarded in the regex that checks for URLs. Therefore URLs with spaces loose their link preview once the Text session is closed.

I'll take a look into implementing this change.

@julien-nc would be interested in your opinion on that.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghigh

Type

No type

Projects

Status

☑️ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions