Autolinker.js
Autolinker.js copied to clipboard
Does not cut links that end with non-latin symbols based on domain correctly
Once upon a time there was this issue reported in remarkable
: https://github.com/jonschlinkert/remarkable/issues/51
Fix worked just fine up to Autolinker version 1.4.1. On 1.4.2+ the non-latin part was once again included together with the latin domain in parsed url. Most likely this is related to https://github.com/gregjacobs/Autolinker.js/pull/201 being merged.
My question is this: would you consider that a regression or breaking change from autolinker
side? Or previous behaviour was wrong and current one is preferable?
Commit with fix for ease of reference (illustrates what autolinker API is used, and what is expected outcome): https://github.com/jonschlinkert/remarkable/commit/719d4c18888d47458e0f997a832909c3f2ab348f
Newest version generates this: -<p><a href="http://www.example.org版权所有">www.example.org版权所有</a></p>
Hey @kibertoad, interesting issue. Seems like a regression to me that it includes the non-latin symbols, and it looks like it doesn't link it at all if not prefixed by http or www. I see the following behavior at the moment:
link('http://www.example.org版权所有') // <a href="http://www.example.org版权所有">example.org版权所有</a>
link('www.example.org版权所有') // <a href="http://www.example.org版权所有">example.org版权所有</a>
link('example.org版权所有') // example.org版权所有 (no link generated)
Do you think the correct behavior would be the following?
link('http://www.example.org版权所有') // <a href="http://www.example.org">example.org</a>版权所有
link('www.example.org版权所有') // <a href="http://www.example.org">example.org</a>版权所有
link('example.org版权所有') // <a href="http://www.example.org">example.org</a>版权所有
Yes, that looks correct. Thank you for the quick response!
Hi @gregjacobs. Do you have some time to take a look at this issue?
I see in this test that such behaviour is expected. https://github.com/gregjacobs/Autolinker.js/blob/master/tests/autolinker-url.spec.ts#L201