kontent-ai / delivery-sdk-js

Kontent Delivery SDK for Javascript
https://kontent.ai
MIT License
50 stars 34 forks source link

UrlSlugResolver does not resolve links with html in Node environment #286

Closed makma closed 4 years ago

makma commented 4 years ago

Brief bug description

UrlSlugResolver does not resolve links with html in Node environment

Repro steps

  1. Download repo
  2. npm i
  3. npm start
  4. check console

Expected behavior

<h3><strong>Logotypes &amp; Badges</strong></h3>
<p><p>ahoj</p></p>
<p><p>ahoj</p></p>
<p><p>ahoj</p></p>

Test environment

Additional context

Hint: https://github.com/Kentico/kontent-delivery-sdk-js/blob/master/lib/parser/adapters/parse5-rich-text.parser.ts

Simply007 commented 4 years ago

@Enngage, unfortunately, @huluvu21 found another use case, that does not work 😢

When you place HTML that in top tag contains HTML attributes, they are striped in the output. I have provided a showcase: https://github.com/Simply007/resolve-url-as-html

If you want to keep it in separate issue - feel free to do so.

Simply007 commented 4 years ago

There is a screenshot of the actual code (context.item is set since the code is using gatsby source plugin):

Ignore the arrow - both href and download attributes are deleted from output

gatsby_resolver_code
Enngage commented 4 years ago

Thank you @Simply007 . I've released a fix in 9.1.1 (https://github.com/Kentico/kontent-delivery-sdk-js/blob/master/CHANGELOG.md#911-2020-04-02)

The only difference is that both browser parser & parse5 automatically change the download attribute to download="" which is however equivalent so it should be ok.