Skip to content

looseUrl option identifies text with multiple periods as a url #59

Open

Description

@rutvik110

Issue:

Currently, the following patterns of text are being identified as url when looseUrl option is true when using linkify.

pattern1 -> 'awdaw....aw'
pattern2 -> 'awdaw...wad...wadw'
and so on...

Expected behaviour:

Technically, this shouldn't be identified as urls as there are multiple periods present consecutively and thus is an invalid url pattern.

Activity

  1. rutvik110 commented on Jan 14, 2024

    @rutvik110
    Author

    I can track this issue to the looseUrlRegex and the issue's arising from including . at this point in regex which allows matching for multiple periods consecutively. Removing . from this section resolves the issue.

    [-a-zA-Z0-9@:%._\+~#=]{2,256}                     

    Complete looseUrlRegex

    r'''^(.*?)((https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//="'`]*))'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions