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

Considers words at the end of a sentence as a valid url when looseUrl = true. #19

Closed MustansirZia closed 3 years ago

MustansirZia commented 4 years ago

Hey!

Really thanks for making this package and it has proven to be quite useful for us. There's one issue however that I found. If looseUrl is set to true then words at the end of sentences are also considered as valid links. It disregards the space after the period. I'm not sure if this is the right package for this issue but I'm still going to add it here.

Here's a live example.

Screenshot 2020-06-08 at 2 37 39 PM

And here's a code snippet.

Linkify(
            text: text,
            maxLines: maxLines,
            overflow: TextOverflow.clip,
            textAlign: TextAlign.start,
            options: LinkifyOptions(
              looseUrl: true,
            ),
            onOpen: (link) async {
              if (await canLaunch(link.url)) {
                await launch(link.url);
              }
            },
)

I'm using package version flutter_linkify: 3.1.2 and flutter version 1.12.13+hotfix.8.

Looking forward to hearing from you! Thanks again for this package. Cheers.

olestole commented 4 years ago

I have the same problem. You could consider changing the _looseurlRegex in UrlLinkifier to (https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)? Check out more examples here

Cretezy commented 4 years ago

This is a good point, will fix in the next version. Moving to parsing library

Cretezy commented 3 years ago

This has been fixed in v3.0.0