-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkify.min.js
1 lines (1 loc) · 13.8 KB
/
linkify.min.js
1
!function(){"use strict";function n(n,t){if(!n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?n:t}function t(n,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(n,t):n.__proto__=t)}function o(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}!function(e){function r(n){n=n||{};for(var t=n.newLine||!1,o=n.ignoreTags||[],e=0;e<o.length;e++)o[e]=o[e].toUpperCase();return{attributes:n.linkAttributes||null,defaultProtocol:n.defaultProtocol||"http",events:n.events||null,format:n.format||a,validate:n.validate||u,formatHref:n.formatHref||a,newLine:n.newLine||!1,nl2br:!!t||n.nl2br||!1,tagName:n.tagName||"a",target:n.target||c,linkClass:n.linkClass||"linkified",ignoreTags:o}}function i(n){for(var t=arguments.length,o=Array(t>1?t-1:0),e=1;t>e;e++)o[e-1]=arguments[e];return"function"==typeof n?n.apply(void 0,o):n}function s(n,t){for(var o=0;o<n.length;o++)if(n[o]==t)return!0;return!1}function a(n){return n}function u(n){return!0}function c(n,t){return"url"===t?"_blank":null}function l(n){return n instanceof g||n instanceof C}function h(n,t,o,e){for(var r=0,i=n.length,s=t,a=[],u=void 0;i>r&&(u=s.next(n[r]));)s=u,r++;if(r>=i)return[];for(;i-1>r;)u=new _(e),a.push(u),s.on(n[r],u),s=u,r++;return u=new _(o),a.push(u),s.on(n[i-1],u),a}var f=Object.freeze({normalize:r,resolve:i,contains:s}),p=function(){function n(t){o(this,n),this.v=t}return n.prototype.toString=function(){return this.v+""},n}(),g=function(e){function r(){return o(this,r),n(this,e.apply(this,arguments))}return t(r,e),r}(p),m=function(e){function r(){return o(this,r),n(this,e.call(this,"@"))}return t(r,e),r}(p),y=function(e){function r(){return o(this,r),n(this,e.call(this,":"))}return t(r,e),r}(p),d=function(e){function r(){return o(this,r),n(this,e.call(this,"."))}return t(r,e),r}(p),b=function(e){function r(){return o(this,r),n(this,e.apply(this,arguments))}return t(r,e),r}(p),v=function(e){function r(){return o(this,r),n(this,e.apply(this,arguments))}return t(r,e),r}(p),k=function(e){function r(){return o(this,r),n(this,e.call(this,"\n"))}return t(r,e),r}(p),w=function(e){function r(){return o(this,r),n(this,e.apply(this,arguments))}return t(r,e),r}(p),O=function(e){function r(){return o(this,r),n(this,e.call(this,"+"))}return t(r,e),r}(p),L=function(e){function r(){return o(this,r),n(this,e.call(this,"#"))}return t(r,e),r}(p),E=function(e){function r(){return o(this,r),n(this,e.apply(this,arguments))}return t(r,e),r}(p),A=function(e){function r(){return o(this,r),n(this,e.call(this,"?"))}return t(r,e),r}(p),S=function(e){function r(){return o(this,r),n(this,e.call(this,"/"))}return t(r,e),r}(p),N=function(e){function r(){return o(this,r),n(this,e.apply(this,arguments))}return t(r,e),r}(p),C=function(e){function r(){return o(this,r),n(this,e.apply(this,arguments))}return t(r,e),r}(p),T=function(e){function r(){return o(this,r),n(this,e.apply(this,arguments))}return t(r,e),r}(p),j=function(e){function r(){return o(this,r),n(this,e.call(this,"{"))}return t(r,e),r}(p),z=function(e){function r(){return o(this,r),n(this,e.call(this,"["))}return t(r,e),r}(p),P=function(e){function r(){return o(this,r),n(this,e.call(this,"("))}return t(r,e),r}(p),x=function(e){function r(){return o(this,r),n(this,e.call(this,"}"))}return t(r,e),r}(p),R=function(e){function r(){return o(this,r),n(this,e.call(this,"]"))}return t(r,e),r}(p),U=function(e){function r(){return o(this,r),n(this,e.call(this,")"))}return t(r,e),r}(p),B={Base:p,DOMAIN:g,AT:m,COLON:y,DOT:d,PUNCTUATION:b,LOCALHOST:v,NL:k,NUM:w,PLUS:O,POUND:L,QUERY:A,PROTOCOL:E,SLASH:S,SYM:N,TLD:C,WS:T,OPENBRACE:j,OPENBRACKET:z,OPENPAREN:P,CLOSEBRACE:x,CLOSEBRACKET:R,CLOSEPAREN:U},D=function(){function n(t){o(this,n),this.v=t,this.type="token",this.isLink=!1}return n.prototype.toString=function(){for(var n=[],t=0;t<this.v.length;t++)n.push(this.v[t].toString());return n.join("")},n.prototype.toHref=function(){return this.toString()},n.prototype.toObject=function(){var n=arguments.length<=0||void 0===arguments[0]?"http":arguments[0];return{type:this.type,value:this.toString(),href:this.toHref(n)}},n}(),H=function(e){function r(t){o(this,r);var i=n(this,e.call(this,t));return i.type="email",i.isLink=!0,i}return t(r,e),r.prototype.toHref=function(){return"mailto:"+this.toString()},r}(D),q=function(e){function r(t){o(this,r);var i=n(this,e.call(this,t));return i.type="text",i}return t(r,e),r}(D),M=function(e){function r(t){o(this,r);var i=n(this,e.call(this,t));return i.type="nl",i}return t(r,e),r}(D),I=function(e){function r(t){o(this,r);var i=n(this,e.call(this,t));return i.type="url",i.isLink=!0,i}return t(r,e),r.prototype.toHref=function(){for(var n=arguments.length<=0||void 0===arguments[0]?"http":arguments[0],t=!1,o=!1,e=this.v,r=[],i=0;e[i]instanceof E;)t=!0,r.push(e[i].toString().toLowerCase()),i++;for(;e[i]instanceof S;)o=!0,r.push(e[i].toString()),i++;for(;l(e[i]);)r.push(e[i].toString().toLowerCase()),i++;for(;i<e.length;i++)r.push(e[i].toString());return r=r.join(""),t||o||(r=n+"://"+r),r},r.prototype.hasProtocol=function(){return this.v[0]instanceof E},r}(D),K={Base:D,EMAIL:H,NL:M,TEXT:q,URL:I},Y=function(){function n(t){o(this,n),this.j=[],this.T=t||null}return n.prototype.on=function(n,t){if(n instanceof Array){for(var o=0;o<n.length;o++)this.j.push([n[o],t]);return this}return this.j.push([n,t]),this},n.prototype.next=function(n){for(var t=0;t<this.j.length;t++){var o=this.j[t],e=o[0],r=o[1];if(this.test(n,e))return r}return!1},n.prototype.accepts=function(){return!!this.T},n.prototype.test=function(n,t){return n===t},n.prototype.emit=function(){return this.T},n}(),_=function(e){function r(){return o(this,r),n(this,e.apply(this,arguments))}return t(r,e),r.prototype.test=function(n,t){return n===t||t instanceof RegExp&&t.test(n)},r}(Y),Q=function(e){function r(){return o(this,r),n(this,e.apply(this,arguments))}return t(r,e),r.prototype.test=function(n,t){return n instanceof t},r}(Y),W="abogado|ac|academy|accountants|active|actor|ad|adult|ae|aero|af|ag|agency|ai|airforce|al|allfinanz|alsace|am|an|android|ao|aq|aquarelle|ar|archi|army|arpa|as|asia|associates|at|attorney|au|auction|audio|autos|aw|ax|axa|az|ba|band|bar|bargains|bayern|bb|bd|be|beer|berlin|best|bf|bg|bh|bi|bid|bike|bio|biz|bj|black|blackfriday|bloomberg|blue|bm|bmw|bn|bnpparibas|bo|boo|boutique|br|brussels|bs|bt|budapest|build|builders|business|buzz|bv|bw|by|bz|bzh|ca|cab|cal|camera|camp|cancerresearch|capetown|capital|caravan|cards|care|career|careers|casa|cash|cat|catering|cc|cd|center|ceo|cern|cf|cg|ch|channel|cheap|christmas|chrome|church|ci|citic|city|ck|cl|claims|cleaning|click|clinic|clothing|club|cm|cn|co|coach|codes|coffee|college|cologne|com|community|company|computer|condos|construction|consulting|contractors|cooking|cool|coop|country|cr|credit|creditcard|cricket|crs|cruises|cu|cuisinella|cv|cw|cx|cy|cymru|cz|dad|dance|dating|day|de|deals|degree|delivery|democrat|dental|dentist|desi|diamonds|diet|digital|direct|directory|discount|dj|dk|dm|dnp|do|domains|durban|dvag|dz|eat|ec|edu|education|ee|eg|email|emerck|energy|engineer|engineering|enterprises|equipment|er|es|esq|estate|et|eu|eurovision|eus|events|everbank|exchange|expert|exposed|fail|farm|fashion|feedback|fi|finance|financial|firmdale|fish|fishing|fitness|fj|fk|flights|florist|flsmidth|fly|fm|fo|foo|forsale|foundation|fr|frl|frogans|fund|furniture|futbol|ga|gal|gallery|gb|gbiz|gd|ge|gent|gf|gg|gh|gi|gift|gifts|gives|gl|glass|gle|global|globo|gm|gmail|gmo|gmx|gn|google|gop|gov|gp|gq|gr|graphics|gratis|green|gripe|gs|gt|gu|guide|guitars|guru|gw|gy|hamburg|haus|healthcare|help|here|hiphop|hiv|hk|hm|hn|holdings|holiday|homes|horse|host|hosting|house|how|hr|ht|hu|ibm|id|ie|il|im|immo|immobilien|in|industries|info|ing|ink|institute|insure|int|international|investments|io|iq|ir|irish|is|it|je|jetzt|jm|jo|jobs|joburg|jp|juegos|kaufen|ke|kg|kh|ki|kim|kitchen|kiwi|km|kn|koeln|kp|kr|krd|kred|kw|ky|kz|la|lacaixa|land|latrobe|lawyer|lb|lc|lds|lease|legal|lgbt|li|life|lighting|limited|limo|link|lk|loans|local|london|lotto|lr|ls|lt|ltda|lu|luxe|luxury|lv|ly|ma|madrid|maison|management|mango|market|marketing|mc|md|me|media|meet|melbourne|meme|memorial|menu|mg|mh|miami|mil|mini|mk|ml|mm|mn|mo|mobi|moda|moe|monash|money|mormon|mortgage|moscow|motorcycles|mov|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|nagoya|name|navy|nc|ne|net|network|neustar|new|nexus|nf|ng|ngo|nhk|ni|ninja|nl|no|np|nr|nra|nrw|nu|nyc|nz|okinawa|om|ong|onl|ooo|org|organic|otsuka|ovh|pa|paris|partners|parts|party|pe|pf|pg|ph|pharmacy|photo|photography|photos|physio|pics|pictures|pink|pizza|pk|pl|place|plumbing|pm|pn|pohl|poker|porn|post|pr|praxi|press|pro|prod|productions|prof|properties|property|ps|pt|pub|pw|py|qa|qpon|quebec|re|realtor|recipes|red|rehab|reise|reisen|reit|ren|rentals|repair|report|republican|rest|restaurant|reviews|rich|rio|rip|ro|rocks|rodeo|rs|rsvp|ru|ruhr|rw|ryukyu|sa|saarland|sarl|sb|sc|sca|scb|schmidt|schule|science|scot|sd|se|services|sexy|sg|sh|shiksha|shoes|si|singles|sj|sk|sl|sm|sn|so|social|software|sohu|solar|solutions|soy|space|spiegel|sr|st|su|supplies|supply|support|surf|surgery|suzuki|sv|sx|sy|sydney|systems|sz|taipei|tatar|tattoo|tax|tc|td|technology|tel|tf|tg|th|tienda|tips|tirol|tj|tk|tl|tm|tn|to|today|tokyo|tools|top|town|toys|tp|tr|trade|training|travel|trust|tt|tui|tv|tw|tz|ua|ug|uk|university|uno|uol|us|uy|uz|va|vacations|vc|ve|vegas|ventures|versicherung|vet|vg|vi|viajes|villas|vision|vlaanderen|vn|vodka|vote|voting|voto|voyage|vu|wales|wang|watch|webcam|website|wed|wedding|wf|whoswho|wien|wiki|williamhill|wme|work|works|world|ws|wtc|wtf|xxx|xyz|yachts|yandex|ye|yoga|yokohama|youtube|yt|za|zip|zm|zone|zw".split("|"),X=/[0-9]/,Z=/[a-z0-9]/,F=":",G=[],J=function(n){return new _(n)},V=B.DOMAIN,$=B.LOCALHOST,nn=B.NUM,tn=B.PROTOCOL,on=B.TLD,en=B.WS,rn=J(),sn=J(nn),an=J(V),un=J(),cn=J(en);rn.on("@",J(B.AT)).on(".",J(B.DOT)).on("+",J(B.PLUS)).on("#",J(B.POUND)).on("?",J(B.QUERY)).on("/",J(B.SLASH)).on(F,J(B.COLON)).on("{",J(B.OPENBRACE)).on("[",J(B.OPENBRACKET)).on("(",J(B.OPENPAREN)).on("}",J(B.CLOSEBRACE)).on("]",J(B.CLOSEBRACKET)).on(")",J(B.CLOSEPAREN)).on(/[,;!]/,J(B.PUNCTUATION)),rn.on(/\n/,J(B.NL)).on(/\s/,cn),cn.on(/[^\S\n]/,cn);for(var ln=0;ln<W.length;ln++){var hn=h(W[ln],rn,on,V);G.push.apply(G,hn)}var fn=h("file",rn,V,V),pn=h("ftp",rn,V,V),gn=h("http",rn,V,V);G.push.apply(G,fn),G.push.apply(G,pn),G.push.apply(G,gn);var mn=fn.pop(),yn=pn.pop(),dn=gn.pop(),bn=J(V),vn=J(tn);yn.on("s",bn).on(F,vn),dn.on("s",bn).on(F,vn),G.push(bn),mn.on(F,vn),bn.on(F,vn);var kn=h("localhost",rn,$,V);G.push.apply(G,kn),rn.on(X,sn),sn.on("-",un).on(X,sn).on(Z,an),an.on("-",un).on(Z,an);for(var wn=0;wn<G.length;wn++)G[wn].on("-",un).on(Z,an);un.on("-",un).on(X,an).on(Z,an),rn.on(/./,J(B.SYM));var On=function(n){for(var t=n.replace(/[A-Z]/g,function(n){return n.toLowerCase()}),o=n.length,e=[],r=0;o>r;){for(var i=rn,s=null,a=null,u=0,c=null,l=-1;o>r&&(a=i.next(t[r]));)s=null,i=a,i.accepts()?(l=0,c=i):l>=0&&l++,u++,r++;if(!(0>l)){r-=l,u-=l;var h=c.emit();e.push(new h(n.substr(r-u,u)))}}return e},Ln=rn,En=Object.freeze({State:_,TOKENS:B,run:On,start:Ln}),An=function(n){return new Q(n)},Sn=B.DOMAIN,Nn=B.AT,Cn=B.COLON,Tn=B.DOT,jn=B.PUNCTUATION,zn=B.LOCALHOST,Pn=B.NL,xn=B.NUM,Rn=B.PLUS,Un=B.POUND,Bn=B.PROTOCOL,Dn=B.QUERY,Hn=B.SLASH,qn=B.SYM,Mn=B.TLD,In=B.OPENBRACE,Kn=B.OPENBRACKET,Yn=B.OPENPAREN,_n=B.CLOSEBRACE,Qn=B.CLOSEBRACKET,Wn=B.CLOSEPAREN,Xn=K.EMAIL,Zn=K.NL,Fn=K.TEXT,Gn=K.URL,Jn=An(),Vn=An(),$n=An(),nt=An(),tt=An(),ot=An(),et=An(Gn),rt=An(),it=An(Gn),st=An(Gn),at=An(),ut=An(),ct=An(),lt=An(),ht=An(Gn),ft=An(Gn),pt=An(Gn),gt=An(),mt=An(),yt=An(),dt=An(),bt=An(),vt=An(Xn),kt=An(),wt=An(Xn),Ot=An(),Lt=An(),Et=An(),At=An(Zn);Jn.on(Pn,At).on(Bn,Vn).on(Hn,$n),Vn.on(Hn,$n),$n.on(Hn,nt),Jn.on(Mn,tt).on(Sn,tt).on(zn,et).on(xn,tt),nt.on(Mn,st).on(Sn,st).on(xn,st).on(zn,st),tt.on(Tn,ot),dt.on(Tn,bt),ot.on(Mn,et).on(Sn,tt).on(xn,tt).on(zn,tt),bt.on(Mn,vt).on(Sn,dt).on(xn,dt).on(zn,dt),et.on(Tn,ot),vt.on(Tn,bt),et.on(Cn,rt).on(Hn,st),rt.on(xn,it),it.on(Hn,st),vt.on(Cn,kt),kt.on(xn,wt);var St=[Sn,Nn,zn,xn,Rn,Un,Bn,Hn,Mn],Nt=[Cn,Tn,Dn,jn,_n,Qn,Wn,In,Kn,Yn,qn];st.on(In,ut).on(Kn,ct).on(Yn,lt),at.on(In,ut).on(Kn,ct).on(Yn,lt),ut.on(_n,st),ct.on(Qn,st),lt.on(Wn,st),ht.on(_n,st),ft.on(Qn,st),pt.on(Wn,st),gt.on(_n,st),mt.on(Qn,st),yt.on(Wn,st),ut.on(St,ht),ct.on(St,ft),lt.on(St,pt),ut.on(Nt,gt),ct.on(Nt,mt),lt.on(Nt,yt),ht.on(St,ht),ft.on(St,ft),pt.on(St,pt),ht.on(Nt,ht),ft.on(Nt,ft),pt.on(Nt,pt),gt.on(St,ht),mt.on(St,ft),yt.on(St,pt),gt.on(Nt,gt),mt.on(Nt,mt),yt.on(Nt,yt),st.on(St,st),at.on(St,st),st.on(Nt,at),at.on(Nt,at);var Ct=[Sn,xn,Rn,Un,Dn,qn,Mn];tt.on(Ct,Ot).on(Nn,Lt),et.on(Ct,Ot).on(Nn,Lt),ot.on(Ct,Ot),Ot.on(Ct,Ot).on(Nn,Lt).on(Tn,Et),Et.on(Ct,Ot),Lt.on(Mn,dt).on(Sn,dt).on(zn,vt);var Tt=function(n){for(var t=n.length,o=0,e=[],r=[];t>o;){for(var i=Jn,s=null,a=null,u=0,c=null,l=-1;t>o&&!(s=i.next(n[o]));)r.push(n[o++]);for(;t>o&&(a=s||i.next(n[o]));)s=null,i=a,i.accepts()?(l=0,c=i):l>=0&&l++,o++,u++;if(0>l)for(var h=o-u;o>h;h++)r.push(n[h]);else{r.length>0&&(e.push(new Fn(r)),r=[]),o-=l,u-=l;var f=c.emit();e.push(new f(n.slice(o-u,o)))}}return r.length>0&&e.push(new Fn(r)),e},jt=K,zt=Jn,Pt=Object.freeze({State:Q,TOKENS:jt,run:Tt,start:zt});Array.isArray||(Array.isArray=function(n){return"[object Array]"===Object.prototype.toString.call(n)});var xt=function(n){return Tt(On(n))},Rt=function(n){for(var t=arguments.length<=1||void 0===arguments[1]?null:arguments[1],o=xt(n),e=[],r=0;r<o.length;r++)!o[r].isLink||t&&o[r].type!==t||e.push(o[r].toObject());return e},Ut=function(n){var t=arguments.length<=1||void 0===arguments[1]?null:arguments[1],o=xt(n);return 1===o.length&&o[0].isLink&&(!t||o[0].type===t)};e.find=Rt,e.options=f,e.parser=Pt,e.scanner=En,e.test=Ut,e.tokenize=xt}(window.linkify=window.linkify||{})}();