prismicio / prismic-helpers

Set of helpers to manage Prismic data

Home Page:https://prismic.io/docs/technical-reference/prismicio-helpers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

asHTML renders hyperlinks with undefined target

seanlail opened this issue · comments

Versions

  • @prismicio/helpers: 2.3.3
  • node: v16.13.1

Reproduction

Using asHTML with the default serializer renders hyperlinks with undefined targets.

Steps to reproduce

  • have a RichTextfield with a hyperlink somewhere. e.g.
  • do not set the target
  • in your code use the asHTML helper: asHTML(myRTF)

What is expected?

Hyperlinks should render correctly:

<a href="mailto:test@test.com">test@test.com</a>

What is actually happening?

The string is undefined: https://github.com/prismicio/prismic-helpers/blob/master/src/lib/serializerHelpers.ts#L75

<a href="mailto:test@test.com" target="undefined" rel="noopener noreferrer">test@test.com</a>

The actual code here is different to the suggested example:
https://prismic.io/docs/technologies/html-serializer#see-all-html-serializer-elements

This issue has been labeled as a bug since it was created using the 🚨 Bug Report Template.

Hi there, thank you so much for the report!

Following our Maintenance Process, we will review your bug report and get back to you next Wednesday. To ensure a smooth review of your issue and avoid unnecessary delays, please make sure your issue includes the following:

  • Information about your environment and packages you use (Node.js version, package names and their versions, etc.)
    Feel free to attach a copy of your package.json file.
  • Any troubleshooting steps you already went through
  • A minimal reproduction of the issue, and/or instructions on how to reproduce it

If you have identified the cause of the bug described in your report and know how to fix it, you're more than welcome to open a pull request addressing it. Check out our quick start guide for a simple contribution process.

If you think your issue is a question (not a bug) and would like quicker support, please close this issue and forward it to an appropriate section on our community forum: https://community.prismic.io

- The Prismic Open-Source Team

Thanks for the report, @seanlail!

I opened a PR fixing this issue here: #59.

Before merging and publishing, I'd like to get a review from @lihbr which will likely happen next week.

If this bug is currently blocking you, however, I'll push it through and publish. Let me know! 🙂

@seanlail This bug should be fixed as of v2.3.4. For more details on the fix, see #59.

You can update to the latest version with the following command:

npm install @prismicio/helpers@latest

If this doesn't resolve the issue, let me know and I'll take another look. Thanks!