milesj / interweave

🌀 React library to safely render HTML, filter attributes, autowrap text with matchers, render emoji characters, and much more.
https://interweave.dev
MIT License
1.1k stars 38 forks source link

urls with hash part are badly interpreted #223

Open ziedHamdi opened 2 years ago

ziedHamdi commented 2 years ago

Hi,

I was testing interweave, I found it really smart to have added emoticon detection (I think a default graphical set would make it twice more attractive). But this is not the topic:

I have the following url in my text:

https://uk.blastingnews.com/food-and-wine/2016/08/here-is-why-eating-at-mcdonald-s-is-bad-for-health-001083227.html#:~:text=Their%20fast%20foo ds%20have%20excessive,obesity%2C%20and%20high%20blood%20pressure.

And only its start ( https://uk.blastingnews.com/food-and-wine/2016/08/here-is-why-eating-at-mcdonald-s-is-bad-for-health-001083227.html#) is interpreted as a url, the rest is a real mess in the text.

So I would recommend two improvements:

Also newWindow shloud be an option of the matcher and not the entire tag in my opinion

Best regards

p.s: there's also an 'over detection' of urls as in the picture because the person who wrote the text didn't put a space after the point in "harm to you.It" so you.it is interpreted as a URL, I think since It is uppercase, we could detect that too

ziedHamdi commented 2 years ago

Capture d’écran de 2022-04-01 10-31-19