linkifyjs icon indicating copy to clipboard operation
linkifyjs copied to clipboard

links encoded with /

Open yarekc opened this issue 8 years ago • 2 comments

In many JS texts treatments, links html are encoded like :

https://html5-chat.com/

Any idea on how handle these cases ?

yarekc avatar Dec 29 '17 13:12 yarekc

Linkify's HTML interface http://soapbox.github.io/linkifyjs/docs/linkify-html.html should theoretically handle this, but HTML character encoding support is temporarily disabled in the built-in HTML parser. This may be fixed in a future release.

nfrasser avatar Mar 03 '18 19:03 nfrasser

I stepped over this issue, but I think in my case I would expect a different result, because my URL is followed by a HTML character reference, that is not part of the URL and gets broken:

const linkifyHtml = require('linkifyjs/html'); // v2.1.6

const html = ""http://xml.example.com/pub/example.dtd"";
const out = linkifyHtml(html, {nl2br: true, className: "", target: ""})
console.info(out);
// Generates:
// &quot;<a href="http://xml.example.com/pub/example.dtd&quot">http://xml.example.com/pub/example.dtd&quot</a>;
// -> the text inside the link contains an invalid character ref "&quot"
//
// but in this case I would expect that the following HTML character reference is not destroyed:
// &quot;<a href="http://xml.example.com/pub/example.dtd&quot">http://xml.example.com/pub/example.dtd</a>&quot;

Actually, I've no idea how these two cases can be automatically distinguished. Maybe add an option?

-> Should I open a new issue for this or would you regard this as related?

ptandler avatar Jun 15 '18 16:06 ptandler

Fixed in the latest Linkify v4

nfrasser avatar Sep 19 '22 01:09 nfrasser