-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathjquery.linkify.min.js
1 lines (1 loc) · 1.01 KB
/
jquery.linkify.min.js
1
function linkify(t,e,o,l,n){return relNoFollow="",n&&(relNoFollow=' rel="nofollow"'),t=0===t.toLowerCase().indexOf("www.")&&o?'<a href="http://'+t+'" target="'+l+'"'+relNoFollow+">"+t+"</a>":'<a href="'+t+'" target="'+l+'"'+relNoFollow+">"+t+"</a>",e&&(t=t.replace(/\B#(\w+)/g,"<a href="+e("$1")+' target="'+l+'"'+relNoFollow+">#$1</a>")),t}!function(t){t.fn.linkify=function(e){return this.each(function(){var o,l,n,a=!0,r="_self",i=!0,f=/((http|https|ftp)\:\/\/|\bw{3}\.)[a-z0-9\-\.]+\.[a-z]{2,3}(:[a-z0-9]*)?\/?([a-z\u00C0-\u017F0-9\-\._\?\,\'\/\\\+&%\$#\=~])*/gi,h=this.innerHTML,c="",u=0;for(e&&("function"==typeof e?o=e:("function"==typeof e.hashtagUrlBuilder&&(o=e.hashtagUrlBuilder),"boolean"==typeof e.includeW3&&(a=e.includeW3),"string"==typeof e.target&&(r=e.target),"boolean"==typeof e.noFollow&&(i=e.noFollow)));null!==(match=f.exec(h));)n=match[0].length,l=linkify(match[0],o,a,r,i),c+=h.substring(u,match.index+n).replace(match[0],l),u=match.index+n;u!==h.length&&(c+=h.substring(u)),t(this).html(c)})}}(jQuery);