gregjacobs / Autolinker.js

Utility to Automatically Link URLs, Email Addresses, Phone Numbers, Twitter handles, and Hashtags in a given block of text/HTML
MIT License
1.48k stars 238 forks source link

urls.wwwMatches usecase #389

Closed filipagh closed 1 year ago

filipagh commented 1 year ago

hello in v4.0 urls.wwwMatches was removed

in some cases we do not want link url like example.com but we want to link [scheme://]www.google.com (must have www. part) so we set options to urls: {schemeMatches: true, wwwMatches: true, tldMatches: false}

this is not possible in v4.0

is possible to revert back this config option ?

gregjacobs commented 1 year ago

Hey @filipagh. I'd like to understand a bit more. If you don't want to link example.com then set tldMatches to false (which you have), and if you want to link http://google.com you set schemeMatches to true (which you also have).

However, with schemeMatches: true, a URL like http://www.google.com would have linked in v3.16.2 even if wwwMatches was set to false. The wwwMatches option only applied for non-scheme matches.

Are you saying that you have a use case to link www.google.com but not google.com (both scheme-less?)

filipagh commented 1 year ago

yes we want link url if it has scheme or has www. on start else leave it as it is

so in same text

[scheme://]www.google.com
scheme://google.com

should be linked and google.com should not

gregjacobs commented 1 year ago

Ah, and just so I understand fully: why wouldn't you want google.com linked in this case?

filipagh commented 1 year ago

main reason was that we did not want to parse links in form like google.com, but we reconsider it and we will parse all valid links

second use case is in mail template and we do not want link text with that format like tenant can have its domain name in template which can be like example.com which is link but not mean to be parsed as link

so use case is to switch mail template format from plain text to html and back and we expect that plain to html to plain will not change original content

so in this case we want to link only schema / www links where we are sure its link

now this is solved by altering custom html to text formater


so no more need for urls.wwwMatches for us