Cretezy / linkify

Low-level link (text, URLs, emails) parsing library in Dart
https://pub.dartlang.org/packages/linkify
MIT License
62 stars 50 forks source link

fix regex doesn't found matches when carriage return(\r) included #9

Closed heyask closed 3 years ago

heyask commented 4 years ago

if string contains \r, then regex cannot find matches.

I tried to edit regex to make matching job to work, I couldn't.

so I added code that remove all \r characters.

I think RegExp() class of dart has bug.

dotAll: true options also doesn't work.

below is test strings. try test.

text = "test_link1: \nhttps://github.com/\ntest_link2 : \nhttps://github.com/"

=> working

text = "test_link1: \r\nhttps://github.com/\r\ntest_link2 : \r\nhttps://github.com/"

=> not working

Cretezy commented 4 years ago

Sorry I didn't see this before. It should match [\n|\r] instead of replacing it.

If you want to update your PR with the new parsers, I can merge

RedyAu commented 4 years ago

I don't know if this issue with the carriage return character is still relevant, but it did cause a minor headache for me. So a simple workaround for anybody in the same situation: myString.replaceAll("\r", "") Do this to the string in the text: property of your Linkify()

Cretezy commented 3 years ago

This has been resolved with #26 in https://github.com/Cretezy/linkify/commit/63e97d597518509baf60b90e44ef828096902e69