You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry this is not an issue but more of a feature request (or maybe I just didn't find it in the readme)
Is there a way to allow or deny specific protocols? In my case I really only want to link http and https protocol urls to get linked. (no ftp or any special application specific protocols)
Does this option already exist and I just missed it?
The text was updated successfully, but these errors were encountered:
So there's no way to set a protocol allow or deny list at this time, but as a workaround for the moment, you could try this in the replaceFn. Something like this:
varlinkedText=Autolinker.link(inputText,{replaceFn : function(match){if(match.getType()==='url'){if(!/https?:\/\//.test(match.getUrl()){// url does not start with 'http://' or 'https://', do not autolinkreturnfalse;}}returntrue;// autolink everything else as usual}});
Thanks @gregjacobs! That's exactly what I needed! I feel a little silly for missing replaceFn in the docs.
Quick note: if any one else needs this bit of code, there's a missing closing paren in the inner if statement
it should be if (!/https?:\/\//.test(match.getUrl())) {
(@gregjacobs - feel free to delete this note [if you can] and update your comment if you like)
I keep waffling between more verbose but easier to read code and Perl-esque one-liners. Here's a one-liner version of the workaround: replaceFn: (match) => !(match.getType() === 'url' && !/https?:\/\//.test(match.getUrl())),
Sorry this is not an issue but more of a feature request (or maybe I just didn't find it in the readme)
Is there a way to allow or deny specific protocols? In my case I really only want to link
http
andhttps
protocol urls to get linked. (noftp
or any special application specific protocols)Does this option already exist and I just missed it?
The text was updated successfully, but these errors were encountered: