Autolinker.js icon indicating copy to clipboard operation
Autolinker.js copied to clipboard

Does not cut links that end with non-latin symbols based on domain correctly

Open kibertoad opened this issue 5 years ago • 4 comments

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>

kibertoad avatar Jun 20 '19 21:06 kibertoad

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>版权所有

gregjacobs avatar Jun 21 '19 01:06 gregjacobs

Yes, that looks correct. Thank you for the quick response!

kibertoad avatar Jun 21 '19 06:06 kibertoad

Hi @gregjacobs. Do you have some time to take a look at this issue?

TrySound avatar Aug 04 '19 14:08 TrySound

I see in this test that such behaviour is expected. https://github.com/gregjacobs/Autolinker.js/blob/master/tests/autolinker-url.spec.ts#L201

TrySound avatar Aug 04 '19 14:08 TrySound