Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

autolinker

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autolinker - npm Package Compare versions

Comparing version 0.24.0 to 0.24.1

6

dist/Autolinker.min.js
/*!
* Autolinker.js
* 0.24.0
* 0.24.1
*
* Copyright(c) 2016 Gregory Jacobs <greg@greg-jacobs.com>
* MIT
* MIT License
*
* https://github.com/gregjacobs/Autolinker.js
*/
!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.Autolinker=b()}):"object"==typeof exports?module.exports=b():a.Autolinker=b()}(this,function(){var a=function(a){a=a||{},this.urls=this.normalizeUrlsCfg(a.urls),this.email="boolean"==typeof a.email?a.email:!0,this.twitter="boolean"==typeof a.twitter?a.twitter:!0,this.phone="boolean"==typeof a.phone?a.phone:!0,this.hashtag=a.hashtag||!1,this.newWindow="boolean"==typeof a.newWindow?a.newWindow:!0,this.stripPrefix="boolean"==typeof a.stripPrefix?a.stripPrefix:!0;var b=this.hashtag;if(b!==!1&&"twitter"!==b&&"facebook"!==b&&"instagram"!==b)throw new Error("invalid `hashtag` cfg - see docs");this.truncate=this.normalizeTruncateCfg(a.truncate),this.className=a.className||"",this.replaceFn=a.replaceFn||null,this.htmlParser=null,this.matchers=null,this.tagBuilder=null};return a.prototype={constructor:a,normalizeUrlsCfg:function(a){return null==a&&(a=!0),"boolean"==typeof a?{schemeMatches:a,wwwMatches:a,tldMatches:a}:{schemeMatches:"boolean"==typeof a.schemeMatches?a.schemeMatches:!0,wwwMatches:"boolean"==typeof a.wwwMatches?a.wwwMatches:!0,tldMatches:"boolean"==typeof a.tldMatches?a.tldMatches:!0}},normalizeTruncateCfg:function(b){return"number"==typeof b?{length:b,location:"end"}:a.Util.defaults(b||{},{length:Number.POSITIVE_INFINITY,location:"end"})},parse:function(a){for(var b=this.getHtmlParser(),c=b.parse(a),d=0,e=[],f=0,g=c.length;g>f;f++){var h=c[f],i=h.getType();if("element"===i&&"a"===h.getTagName())h.isClosing()?d=Math.max(d-1,0):d++;else if("text"===i&&0===d){var j=this.parseText(h.getText(),h.getOffset());e.push.apply(e,j)}}return e=this.compactMatches(e),this.hashtag||(e=e.filter(function(a){return"hashtag"!==a.getType()})),this.email||(e=e.filter(function(a){return"email"!==a.getType()})),this.phone||(e=e.filter(function(a){return"phone"!==a.getType()})),this.twitter||(e=e.filter(function(a){return"twitter"!==a.getType()})),this.urls.schemeMatches||(e=e.filter(function(a){return"url"!==a.getType()||"scheme"!==a.getUrlMatchType()})),this.urls.wwwMatches||(e=e.filter(function(a){return"url"!==a.getType()||"www"!==a.getUrlMatchType()})),this.urls.tldMatches||(e=e.filter(function(a){return"url"!==a.getType()||"tld"!==a.getUrlMatchType()})),e},compactMatches:function(a){a.sort(function(a,b){return a.getOffset()-b.getOffset()});for(var b=0;b<a.length-1;b++)for(var c=a[b],d=c.getOffset()+c.getMatchedText().length;b+1<a.length&&a[b+1].getOffset()<=d;)a.splice(b+1,1);return a},parseText:function(a,b){b=b||0;for(var c=this.getMatchers(),d=[],e=0,f=c.length;f>e;e++){for(var g=c[e].parseMatches(a),h=0,i=g.length;i>h;h++)g[h].setOffset(b+g[h].getOffset());d.push.apply(d,g)}return d},link:function(a){if(!a)return"";for(var b=this.parse(a),c=[],d=0,e=0,f=b.length;f>e;e++){var g=b[e];c.push(a.substring(d,g.getOffset())),c.push(this.createMatchReturnVal(g)),d=g.getOffset()+g.getMatchedText().length}return c.push(a.substring(d)),c.join("")},createMatchReturnVal:function(b){var c;if(this.replaceFn&&(c=this.replaceFn.call(this,this,b)),"string"==typeof c)return c;if(c===!1)return b.getMatchedText();if(c instanceof a.HtmlTag)return c.toAnchorString();var d=this.getTagBuilder(),e=d.build(b);return e.toAnchorString()},getHtmlParser:function(){var b=this.htmlParser;return b||(b=this.htmlParser=new a.htmlParser.HtmlParser),b},getMatchers:function(){if(this.matchers)return this.matchers;var b=a.matcher,c=[new b.Hashtag({serviceName:this.hashtag}),new b.Email,new b.Phone,new b.Twitter,new b.Url({stripPrefix:this.stripPrefix})];return this.matchers=c},getTagBuilder:function(){var b=this.tagBuilder;return b||(b=this.tagBuilder=new a.AnchorTagBuilder({newWindow:this.newWindow,truncate:this.truncate,className:this.className})),b}},a.link=function(b,c){var d=new a(c);return d.link(b)},a.match={},a.matcher={},a.htmlParser={},a.truncate={},a.Util={abstractMethod:function(){throw"abstract"},trimRegex:/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,assign:function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},defaults:function(a,b){for(var c in b)b.hasOwnProperty(c)&&void 0===a[c]&&(a[c]=b[c]);return a},extend:function(b,c){var d=b.prototype,e=function(){};e.prototype=d;var f;f=c.hasOwnProperty("constructor")?c.constructor:function(){d.constructor.apply(this,arguments)};var g=f.prototype=new e;return g.constructor=f,g.superclass=d,delete c.constructor,a.Util.assign(g,c),f},ellipsis:function(a,b,c){return a.length>b&&(c=null==c?"..":c,a=a.substring(0,b-c.length)+c),a},indexOf:function(a,b){if(Array.prototype.indexOf)return a.indexOf(b);for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},splitAndCapture:function(a,b){if(!b.global)throw new Error("`splitRegex` must have the 'g' flag set");for(var c,d=[],e=0;c=b.exec(a);)d.push(a.substring(e,c.index)),d.push(c[0]),e=c.index+c[0].length;return d.push(a.substring(e)),d},trim:function(a){return a.replace(this.trimRegex,"")}},a.HtmlTag=a.Util.extend(Object,{whitespaceRegex:/\s+/,constructor:function(b){a.Util.assign(this,b),this.innerHtml=this.innerHtml||this.innerHTML},setTagName:function(a){return this.tagName=a,this},getTagName:function(){return this.tagName||""},setAttr:function(a,b){var c=this.getAttrs();return c[a]=b,this},getAttr:function(a){return this.getAttrs()[a]},setAttrs:function(b){var c=this.getAttrs();return a.Util.assign(c,b),this},getAttrs:function(){return this.attrs||(this.attrs={})},setClass:function(a){return this.setAttr("class",a)},addClass:function(b){for(var c,d=this.getClass(),e=this.whitespaceRegex,f=a.Util.indexOf,g=d?d.split(e):[],h=b.split(e);c=h.shift();)-1===f(g,c)&&g.push(c);return this.getAttrs()["class"]=g.join(" "),this},removeClass:function(b){for(var c,d=this.getClass(),e=this.whitespaceRegex,f=a.Util.indexOf,g=d?d.split(e):[],h=b.split(e);g.length&&(c=h.shift());){var i=f(g,c);-1!==i&&g.splice(i,1)}return this.getAttrs()["class"]=g.join(" "),this},getClass:function(){return this.getAttrs()["class"]||""},hasClass:function(a){return-1!==(" "+this.getClass()+" ").indexOf(" "+a+" ")},setInnerHtml:function(a){return this.innerHtml=a,this},getInnerHtml:function(){return this.innerHtml||""},toAnchorString:function(){var a=this.getTagName(),b=this.buildAttrsStr();return b=b?" "+b:"",["<",a,b,">",this.getInnerHtml(),"</",a,">"].join("")},buildAttrsStr:function(){if(!this.attrs)return"";var a=this.getAttrs(),b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c+'="'+a[c]+'"');return b.join(" ")}}),a.RegexLib=function(){var a="A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢴऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛱ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞭꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",b="0-9٠-٩۰-۹߀-߉०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯෦-෯๐-๙໐-໙༠-༩၀-၉႐-႙០-៩᠐-᠙᥆-᥏᧐-᧙᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙꘠-꘩꣐-꣙꤀-꤉꧐-꧙꧰-꧹꩐-꩙꯰-꯹0-9",c=a+b,d=new RegExp("["+c+".\\-]*["+c+"\\-]"),e=/(?:international|construction|contractors|enterprises|photography|productions|foundation|immobilien|industries|management|properties|technology|christmas|community|directory|education|equipment|institute|marketing|solutions|vacations|bargains|boutique|builders|catering|cleaning|clothing|computer|democrat|diamonds|graphics|holdings|lighting|partners|plumbing|supplies|training|ventures|academy|careers|company|cruises|domains|exposed|flights|florist|gallery|guitars|holiday|kitchen|neustar|okinawa|recipes|rentals|reviews|shiksha|singles|support|systems|agency|berlin|camera|center|coffee|condos|dating|estate|events|expert|futbol|kaufen|luxury|maison|monash|museum|nagoya|photos|repair|report|social|supply|tattoo|tienda|travel|viajes|villas|vision|voting|voyage|actor|build|cards|cheap|codes|dance|email|glass|house|mango|ninja|parts|photo|press|shoes|solar|today|tokyo|tools|watch|works|aero|arpa|asia|best|bike|blue|buzz|camp|club|cool|coop|farm|fish|gift|guru|info|jobs|kiwi|kred|land|limo|link|menu|mobi|moda|name|pics|pink|post|qpon|rich|ruhr|sexy|tips|vote|voto|wang|wien|wiki|zone|bar|bid|biz|cab|cat|ceo|com|edu|gov|int|kim|mil|net|onl|org|pro|pub|red|tel|uno|wed|xxx|xyz|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)\b/;return{alphaNumericCharsStr:c,domainNameRegex:d,tldRegex:e}}(),a.AnchorTagBuilder=a.Util.extend(Object,{constructor:function(b){a.Util.assign(this,b)},build:function(b){return new a.HtmlTag({tagName:"a",attrs:this.createAttrs(b.getType(),b.getAnchorHref()),innerHtml:this.processAnchorText(b.getAnchorText())})},createAttrs:function(a,b){var c={href:b},d=this.createCssClass(a);return d&&(c["class"]=d),this.newWindow&&(c.target="_blank"),c},createCssClass:function(a){var b=this.className;return b?b+" "+b+"-"+a:""},processAnchorText:function(a){return a=this.doTruncate(a)},doTruncate:function(b){var c=this.truncate;if(!c)return b;var d=c.length,e=c.location;return"smart"===e?a.truncate.TruncateSmart(b,d,".."):"middle"===e?a.truncate.TruncateMiddle(b,d,".."):a.truncate.TruncateEnd(b,d,"..")}}),a.htmlParser.HtmlParser=a.Util.extend(Object,{htmlRegex:function(){var a=/!--([\s\S]+?)--/,b=/[0-9a-zA-Z][0-9a-zA-Z:]*/,c=/[^\s\0"'>\/=\x01-\x1F\x7F]+/,d=/(?:"[^"]*?"|'[^']*?'|[^'"=<>`\s]+)/,e=c.source+"(?:\\s*=\\s*"+d.source+")?";return new RegExp(["(?:","<(!DOCTYPE)","(?:","\\s+","(?:",e,"|",d.source+")",")*",">",")","|","(?:","<(/)?","(?:",a.source,"|","(?:","("+b.source+")","(?:","\\s+",e,")*","\\s*/?",")",")",">",")"].join(""),"gi")}(),htmlCharacterEntitiesRegex:/(&nbsp;|&#160;|&lt;|&#60;|&gt;|&#62;|&quot;|&#34;|&#39;)/gi,parse:function(a){for(var b,c,d=this.htmlRegex,e=0,f=[];null!==(b=d.exec(a));){var g=b[0],h=b[3],i=b[1]||b[4],j=!!b[2],k=b.index,l=a.substring(e,k);l&&(c=this.parseTextAndEntityNodes(e,l),f.push.apply(f,c)),f.push(h?this.createCommentNode(k,g,h):this.createElementNode(k,g,i,j)),e=k+g.length}if(e<a.length){var m=a.substring(e);m&&(c=this.parseTextAndEntityNodes(e,m),f.push.apply(f,c))}return f},parseTextAndEntityNodes:function(b,c){for(var d=[],e=a.Util.splitAndCapture(c,this.htmlCharacterEntitiesRegex),f=0,g=e.length;g>f;f+=2){var h=e[f],i=e[f+1];h&&(d.push(this.createTextNode(b,h)),b+=h.length),i&&(d.push(this.createEntityNode(b,i)),b+=i.length)}return d},createCommentNode:function(b,c,d){return new a.htmlParser.CommentNode({offset:b,text:c,comment:a.Util.trim(d)})},createElementNode:function(b,c,d,e){return new a.htmlParser.ElementNode({offset:b,text:c,tagName:d.toLowerCase(),closing:e})},createEntityNode:function(b,c){return new a.htmlParser.EntityNode({offset:b,text:c})},createTextNode:function(b,c){return new a.htmlParser.TextNode({offset:b,text:c})}}),a.htmlParser.HtmlNode=a.Util.extend(Object,{offset:void 0,text:void 0,constructor:function(b){if(a.Util.assign(this,b),null==this.offset)throw new Error("`offset` cfg required");if(null==this.text)throw new Error("`text` cfg required")},getType:a.Util.abstractMethod,getOffset:function(){return this.offset},getText:function(){return this.text}}),a.htmlParser.CommentNode=a.Util.extend(a.htmlParser.HtmlNode,{comment:"",getType:function(){return"comment"},getComment:function(){return this.comment}}),a.htmlParser.ElementNode=a.Util.extend(a.htmlParser.HtmlNode,{tagName:"",closing:!1,getType:function(){return"element"},getTagName:function(){return this.tagName},isClosing:function(){return this.closing}}),a.htmlParser.EntityNode=a.Util.extend(a.htmlParser.HtmlNode,{getType:function(){return"entity"}}),a.htmlParser.TextNode=a.Util.extend(a.htmlParser.HtmlNode,{getType:function(){return"text"}}),a.match.Match=a.Util.extend(Object,{constructor:function(a,b){if(null==a)throw new Error("`matchedText` arg required");if(null==b)throw new Error("`offset` arg required");this.matchedText=a,this.offset=b},getType:a.Util.abstractMethod,getMatchedText:function(){return this.matchedText},setOffset:function(a){this.offset=a},getOffset:function(){return this.offset},getAnchorHref:a.Util.abstractMethod,getAnchorText:a.Util.abstractMethod}),a.match.Email=a.Util.extend(a.match.Match,{constructor:function(b,c,d){if(a.match.Match.prototype.constructor.call(this,b,c),!d)throw new Error("`email` arg required");this.email=d},getType:function(){return"email"},getEmail:function(){return this.email},getAnchorHref:function(){return"mailto:"+this.email},getAnchorText:function(){return this.email}}),a.match.Hashtag=a.Util.extend(a.match.Match,{constructor:function(b,c,d,e){if(a.match.Match.prototype.constructor.call(this,b,c),!e)throw new Error("`hashtag` arg required");this.serviceName=d,this.hashtag=e},getType:function(){return"hashtag"},getServiceName:function(){return this.serviceName},getHashtag:function(){return this.hashtag},getAnchorHref:function(){var a=this.serviceName,b=this.hashtag;switch(a){case"twitter":return"https://twitter.com/hashtag/"+b;case"facebook":return"https://www.facebook.com/hashtag/"+b;case"instagram":return"https://instagram.com/explore/tags/"+b;default:throw new Error("Unknown service name to point hashtag to: ",a)}},getAnchorText:function(){return"#"+this.hashtag}}),a.match.Phone=a.Util.extend(a.match.Match,{constructor:function(b,c,d,e){if(a.match.Match.prototype.constructor.call(this,b,c),!d)throw new Error("`number` arg required");if(null==e)throw new Error("`plusSign` arg required");this.number=d,this.plusSign=e},getType:function(){return"phone"},getNumber:function(){return this.number},getAnchorHref:function(){return"tel:"+(this.plusSign?"+":"")+this.number},getAnchorText:function(){return this.matchedText}}),a.match.Twitter=a.Util.extend(a.match.Match,{constructor:function(b,c,d){if(a.match.Match.prototype.constructor.call(this,b,c),!d)throw new Error("`twitterHandle` arg required");this.twitterHandle=d},getType:function(){return"twitter"},getTwitterHandle:function(){return this.twitterHandle},getAnchorHref:function(){return"https://twitter.com/"+this.twitterHandle},getAnchorText:function(){return"@"+this.twitterHandle}}),a.match.Url=a.Util.extend(a.match.Match,{constructor:function(b,c,d,e,f,g,h){if(a.match.Match.prototype.constructor.call(this,b,c),"scheme"!==e&&"www"!==e&&"tld"!==e)throw new Error('`urlMatchType` must be one of: "scheme", "www", or "tld"');if(!d)throw new Error("`url` arg required");if(null==f)throw new Error("`protocolUrlMatch` arg required");if(null==g)throw new Error("`protocolRelativeMatch` arg required");if(null==h)throw new Error("`stripPrefix` arg required");this.urlMatchType=e,this.url=d,this.protocolUrlMatch=f,this.protocolRelativeMatch=g,this.stripPrefix=h},urlPrefixRegex:/^(https?:\/\/)?(www\.)?/i,protocolRelativeRegex:/^\/\//,protocolPrepended:!1,getType:function(){return"url"},getUrlMatchType:function(){return this.urlMatchType},getUrl:function(){var a=this.url;return this.protocolRelativeMatch||this.protocolUrlMatch||this.protocolPrepended||(a=this.url="http://"+a,this.protocolPrepended=!0),a},getAnchorHref:function(){var a=this.getUrl();return a.replace(/&amp;/g,"&")},getAnchorText:function(){var a=this.getMatchedText();return this.protocolRelativeMatch&&(a=this.stripProtocolRelativePrefix(a)),this.stripPrefix&&(a=this.stripUrlPrefix(a)),a=this.removeTrailingSlash(a)},stripUrlPrefix:function(a){return a.replace(this.urlPrefixRegex,"")},stripProtocolRelativePrefix:function(a){return a.replace(this.protocolRelativeRegex,"")},removeTrailingSlash:function(a){return"/"===a.charAt(a.length-1)&&(a=a.slice(0,-1)),a}}),a.matcher.Matcher=a.Util.extend(Object,{constructor:function(b){a.Util.assign(this,b)},parseMatches:a.Util.abstractMethod}),a.matcher.Email=a.Util.extend(a.matcher.Matcher,{matcherRegex:function(){var b=a.RegexLib.alphaNumericCharsStr,c=new RegExp("["+b+"\\-;:&=+$.,]+@"),d=a.RegexLib.domainNameRegex,e=a.RegexLib.tldRegex;return new RegExp([c.source,d.source,"\\.",e.source].join(""),"gi")}(),parseMatches:function(b){for(var c,d=this.matcherRegex,e=[];null!==(c=d.exec(b));){var f=c[0];e.push(new a.match.Email(f,c.index,f))}return e}}),a.matcher.Hashtag=a.Util.extend(a.matcher.Matcher,{matcherRegex:new RegExp("#[_"+a.RegexLib.alphaNumericCharsStr+"]{1,139}","g"),nonWordCharRegex:new RegExp("[^"+a.RegexLib.alphaNumericCharsStr+"]"),constructor:function(){a.matcher.Matcher.prototype.constructor.apply(this,arguments)},parseMatches:function(b){for(var c,d=this.matcherRegex,e=this.nonWordCharRegex,f=this.serviceName,g=[];null!==(c=d.exec(b));){var h=c.index,i=b.charAt(h-1);if(0===h||e.test(i)){var j=c[0],k=c[0].slice(1);g.push(new a.match.Hashtag(j,h,f,k))}}return g}}),a.matcher.Phone=a.Util.extend(a.matcher.Matcher,{matcherRegex:/(?:(\+)?\d{1,3}[-\040.])?\(?\d{3}\)?[-\040.]?\d{3}[-\040.]\d{4}/g,parseMatches:function(b){for(var c,d=this.matcherRegex,e=[];null!==(c=d.exec(b));){var f=c[0],g=f.replace(/\D/g,""),h=!!c[1];e.push(new a.match.Phone(f,c.index,g,h))}return e}}),a.matcher.Twitter=a.Util.extend(a.matcher.Matcher,{matcherRegex:new RegExp("@[_"+a.RegexLib.alphaNumericCharsStr+"]{1,20}","g"),nonWordCharRegex:new RegExp("[^"+a.RegexLib.alphaNumericCharsStr+"]"),parseMatches:function(b){for(var c,d=this.matcherRegex,e=this.nonWordCharRegex,f=[];null!==(c=d.exec(b));){var g=c.index,h=b.charAt(g-1);if(0===g||e.test(h)){var i=c[0],j=c[0].slice(1);f.push(new a.match.Twitter(i,g,j))}}return f}}),a.matcher.Url=a.Util.extend(a.matcher.Matcher,{matcherRegex:function(){var b=/(?:[A-Za-z][-.+A-Za-z0-9]*:(?![A-Za-z][-.+A-Za-z0-9]*:\/\/)(?!\d+\/?)(?:\/\/)?)/,c=/(?:www\.)/,d=a.RegexLib.domainNameRegex,e=a.RegexLib.tldRegex,f=a.RegexLib.alphaNumericCharsStr,g=new RegExp("["+f+"\\-+&@#/%=~_()|'$*\\[\\]?!:,.;]*["+f+"\\-+&@#/%=~_()|'$*\\[\\]]");return new RegExp(["(?:","(",b.source,d.source,")","|","(","(//)?",c.source,d.source,")","|","(","(//)?",d.source+"\\.",e.source,")",")","(?:"+g.source+")?"].join(""),"gi")}(),wordCharRegExp:/\w/,openParensRe:/\(/g,closeParensRe:/\)/g,constructor:function(){if(a.matcher.Matcher.prototype.constructor.apply(this,arguments),null==this.stripPrefix)throw new Error("`stripPrefix` cfg required")},parseMatches:function(b){for(var c,d=this.matcherRegex,e=this.stripPrefix,f=[];null!==(c=d.exec(b));){var g=c[0],h=c[1],i=c[2],j=c[3],k=c[5],l=c.index,m=j||k,n=b.charAt(l-1);if(a.matcher.UrlMatchValidator.isValid(g,h)&&!(l>0&&"@"===n||l>0&&m&&this.wordCharRegExp.test(n))){if(this.matchHasUnbalancedClosingParen(g))g=g.substr(0,g.length-1);else{var o=this.matchHasInvalidCharAfterTld(g,h);o>-1&&(g=g.substr(0,o))}var p=h?"scheme":i?"www":"tld",q=!!h;f.push(new a.match.Url(g,l,g,p,q,!!m,e))}}return f},matchHasUnbalancedClosingParen:function(a){var b=a.charAt(a.length-1);if(")"===b){var c=a.match(this.openParensRe),d=a.match(this.closeParensRe),e=c&&c.length||0,f=d&&d.length||0;if(f>e)return!0}return!1},matchHasInvalidCharAfterTld:function(a,b){if(!a)return-1;var c=0;b&&(c=a.indexOf(":"),a=a.slice(c));var d=/^((.?\/\/)?[A-Za-z0-9\u00C0-\u017F\.\-]*[A-Za-z0-9\u00C0-\u017F\-]\.[A-Za-z]+)/,e=d.exec(a);return null===e?-1:(c+=e[1].length,a=a.slice(e[1].length),/^[^.A-Za-z:\/?#]/.test(a)?c:-1)}}),a.matcher.UrlMatchValidator={hasFullProtocolRegex:/^[A-Za-z][-.+A-Za-z0-9]*:\/\//,uriSchemeRegex:/^[A-Za-z][-.+A-Za-z0-9]*:/,hasWordCharAfterProtocolRegex:/:[^\s]*?[A-Za-z\u00C0-\u017F]/,isValid:function(a,b){return b&&!this.isValidUriScheme(b)||this.urlMatchDoesNotHaveProtocolOrDot(a,b)||this.urlMatchDoesNotHaveAtLeastOneWordChar(a,b)?!1:!0},isValidUriScheme:function(a){var b=a.match(this.uriSchemeRegex)[0].toLowerCase();return"javascript:"!==b&&"vbscript:"!==b},urlMatchDoesNotHaveProtocolOrDot:function(a,b){return!(!a||b&&this.hasFullProtocolRegex.test(b)||-1!==a.indexOf("."))},urlMatchDoesNotHaveAtLeastOneWordChar:function(a,b){return a&&b?!this.hasWordCharAfterProtocolRegex.test(a):!1}},a.truncate.TruncateEnd=function(b,c,d){return a.Util.ellipsis(b,c,d)},a.truncate.TruncateMiddle=function(a,b,c){if(a.length<=b)return a;var d=b-c.length,e="";return d>0&&(e=a.substr(-1*Math.floor(d/2))),(a.substr(0,Math.ceil(d/2))+c+e).substr(0,b)},a.truncate.TruncateSmart=function(a,b,c){var d=function(a){var b={},c=a,d=c.match(/^([a-z]+):\/\//i);return d&&(b.scheme=d[1],c=c.substr(d[0].length)),d=c.match(/^(.*?)(?=(\?|#|\/|$))/i),d&&(b.host=d[1],c=c.substr(d[0].length)),d=c.match(/^\/(.*?)(?=(\?|#|$))/i),d&&(b.path=d[1],c=c.substr(d[0].length)),d=c.match(/^\?(.*?)(?=(#|$))/i),d&&(b.query=d[1],c=c.substr(d[0].length)),d=c.match(/^#(.*?)$/i),d&&(b.fragment=d[1]),b},e=function(a){var b="";return a.scheme&&a.host&&(b+=a.scheme+"://"),a.host&&(b+=a.host),a.path&&(b+="/"+a.path),a.query&&(b+="?"+a.query),a.fragment&&(b+="#"+a.fragment),b},f=function(a,b){var d=b/2,e=Math.ceil(d),f=-1*Math.floor(d),g="";return 0>f&&(g=a.substr(f)),a.substr(0,e)+c+g};if(a.length<=b)return a;var g=b-c.length,h=d(a);if(h.query){var i=h.query.match(/^(.*?)(?=(\?|\#))(.*?)$/i);i&&(h.query=h.query.substr(0,i[1].length),a=e(h))}if(a.length<=b)return a;if(h.host&&(h.host=h.host.replace(/^www\./,""),a=e(h)),a.length<=b)return a;var j="";if(h.host&&(j+=h.host),j.length>=g)return h.host.length==b?(h.host.substr(0,b-c.length)+c).substr(0,b):f(j,g).substr(0,b);var k="";if(h.path&&(k+="/"+h.path),h.query&&(k+="?"+h.query),k){if((j+k).length>=g){if((j+k).length==b)return(j+k).substr(0,b);var l=g-j.length;return(j+f(k,l)).substr(0,b)}j+=k}if(h.fragment){var m="#"+h.fragment;if((j+m).length>=g){if((j+m).length==b)return(j+m).substr(0,b);var n=g-j.length;return(j+f(m,n)).substr(0,b)}j+=m}if(h.scheme&&h.host){var o=h.scheme+"://";if((j+o).length<g)return(o+j).substr(0,b)}if(j.length<=b)return j;var p="";return g>0&&(p=j.substr(-1*Math.floor(g/2))),(j.substr(0,Math.ceil(g/2))+c+p).substr(0,b)},a});
!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.Autolinker=e()}(this,function(){var t=function(t){t=t||{},this.urls=this.normalizeUrlsCfg(t.urls),this.email="boolean"==typeof t.email?t.email:!0,this.twitter="boolean"==typeof t.twitter?t.twitter:!0,this.phone="boolean"==typeof t.phone?t.phone:!0,this.hashtag=t.hashtag||!1,this.newWindow="boolean"==typeof t.newWindow?t.newWindow:!0,this.stripPrefix="boolean"==typeof t.stripPrefix?t.stripPrefix:!0;var e=this.hashtag;if(e!==!1&&"twitter"!==e&&"facebook"!==e&&"instagram"!==e)throw new Error("invalid `hashtag` cfg - see docs");this.truncate=this.normalizeTruncateCfg(t.truncate),this.className=t.className||"",this.replaceFn=t.replaceFn||null,this.htmlParser=null,this.matchers=null,this.tagBuilder=null};return t.prototype={constructor:t,normalizeUrlsCfg:function(t){return null==t&&(t=!0),"boolean"==typeof t?{schemeMatches:t,wwwMatches:t,tldMatches:t}:{schemeMatches:"boolean"==typeof t.schemeMatches?t.schemeMatches:!0,wwwMatches:"boolean"==typeof t.wwwMatches?t.wwwMatches:!0,tldMatches:"boolean"==typeof t.tldMatches?t.tldMatches:!0}},normalizeTruncateCfg:function(e){return"number"==typeof e?{length:e,location:"end"}:t.Util.defaults(e||{},{length:Number.POSITIVE_INFINITY,location:"end"})},parse:function(t){for(var e=this.getHtmlParser(),r=e.parse(t),n=0,s=[],i=0,a=r.length;a>i;i++){var o=r[i],h=o.getType();if("element"===h&&"a"===o.getTagName())o.isClosing()?n=Math.max(n-1,0):n++;else if("text"===h&&0===n){var c=this.parseText(o.getText(),o.getOffset());s.push.apply(s,c)}}return s=this.compactMatches(s),this.hashtag||(s=s.filter(function(t){return"hashtag"!==t.getType()})),this.email||(s=s.filter(function(t){return"email"!==t.getType()})),this.phone||(s=s.filter(function(t){return"phone"!==t.getType()})),this.twitter||(s=s.filter(function(t){return"twitter"!==t.getType()})),this.urls.schemeMatches||(s=s.filter(function(t){return"url"!==t.getType()||"scheme"!==t.getUrlMatchType()})),this.urls.wwwMatches||(s=s.filter(function(t){return"url"!==t.getType()||"www"!==t.getUrlMatchType()})),this.urls.tldMatches||(s=s.filter(function(t){return"url"!==t.getType()||"tld"!==t.getUrlMatchType()})),s},compactMatches:function(t){t.sort(function(t,e){return t.getOffset()-e.getOffset()});for(var e=0;e<t.length-1;e++)for(var r=t[e],n=r.getOffset()+r.getMatchedText().length;e+1<t.length&&t[e+1].getOffset()<=n;)t.splice(e+1,1);return t},parseText:function(t,e){e=e||0;for(var r=this.getMatchers(),n=[],s=0,i=r.length;i>s;s++){for(var a=r[s].parseMatches(t),o=0,h=a.length;h>o;o++)a[o].setOffset(e+a[o].getOffset());n.push.apply(n,a)}return n},link:function(t){if(!t)return"";for(var e=this.parse(t),r=[],n=0,s=0,i=e.length;i>s;s++){var a=e[s];r.push(t.substring(n,a.getOffset())),r.push(this.createMatchReturnVal(a)),n=a.getOffset()+a.getMatchedText().length}return r.push(t.substring(n)),r.join("")},createMatchReturnVal:function(e){var r;if(this.replaceFn&&(r=this.replaceFn.call(this,this,e)),"string"==typeof r)return r;if(r===!1)return e.getMatchedText();if(r instanceof t.HtmlTag)return r.toAnchorString();var n=this.getTagBuilder(),s=n.build(e);return s.toAnchorString()},getHtmlParser:function(){var e=this.htmlParser;return e||(e=this.htmlParser=new t.htmlParser.HtmlParser),e},getMatchers:function(){if(this.matchers)return this.matchers;var e=t.matcher,r=[new e.Hashtag({serviceName:this.hashtag}),new e.Email,new e.Phone,new e.Twitter,new e.Url({stripPrefix:this.stripPrefix})];return this.matchers=r},getTagBuilder:function(){var e=this.tagBuilder;return e||(e=this.tagBuilder=new t.AnchorTagBuilder({newWindow:this.newWindow,truncate:this.truncate,className:this.className})),e}},t.link=function(e,r){var n=new t(r);return n.link(e)},t.match={},t.matcher={},t.htmlParser={},t.truncate={},t.Util={abstractMethod:function(){throw"abstract"},trimRegex:/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,assign:function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t},defaults:function(t,e){for(var r in e)e.hasOwnProperty(r)&&void 0===t[r]&&(t[r]=e[r]);return t},extend:function(e,r){var n=e.prototype,s=function(){};s.prototype=n;var i;i=r.hasOwnProperty("constructor")?r.constructor:function(){n.constructor.apply(this,arguments)};var a=i.prototype=new s;return a.constructor=i,a.superclass=n,delete r.constructor,t.Util.assign(a,r),i},ellipsis:function(t,e,r){return t.length>e&&(r=null==r?"..":r,t=t.substring(0,e-r.length)+r),t},indexOf:function(t,e){if(Array.prototype.indexOf)return t.indexOf(e);for(var r=0,n=t.length;n>r;r++)if(t[r]===e)return r;return-1},splitAndCapture:function(t,e){for(var r,n=[],s=0;r=e.exec(t);)n.push(t.substring(s,r.index)),n.push(r[0]),s=r.index+r[0].length;return n.push(t.substring(s)),n},trim:function(t){return t.replace(this.trimRegex,"")}},t.HtmlTag=t.Util.extend(Object,{whitespaceRegex:/\s+/,constructor:function(e){t.Util.assign(this,e),this.innerHtml=this.innerHtml||this.innerHTML},setTagName:function(t){return this.tagName=t,this},getTagName:function(){return this.tagName||""},setAttr:function(t,e){var r=this.getAttrs();return r[t]=e,this},getAttr:function(t){return this.getAttrs()[t]},setAttrs:function(e){var r=this.getAttrs();return t.Util.assign(r,e),this},getAttrs:function(){return this.attrs||(this.attrs={})},setClass:function(t){return this.setAttr("class",t)},addClass:function(e){for(var r,n=this.getClass(),s=this.whitespaceRegex,i=t.Util.indexOf,a=n?n.split(s):[],o=e.split(s);r=o.shift();)-1===i(a,r)&&a.push(r);return this.getAttrs()["class"]=a.join(" "),this},removeClass:function(e){for(var r,n=this.getClass(),s=this.whitespaceRegex,i=t.Util.indexOf,a=n?n.split(s):[],o=e.split(s);a.length&&(r=o.shift());){var h=i(a,r);-1!==h&&a.splice(h,1)}return this.getAttrs()["class"]=a.join(" "),this},getClass:function(){return this.getAttrs()["class"]||""},hasClass:function(t){return-1!==(" "+this.getClass()+" ").indexOf(" "+t+" ")},setInnerHtml:function(t){return this.innerHtml=t,this},getInnerHtml:function(){return this.innerHtml||""},toAnchorString:function(){var t=this.getTagName(),e=this.buildAttrsStr();return e=e?" "+e:"",["<",t,e,">",this.getInnerHtml(),"</",t,">"].join("")},buildAttrsStr:function(){if(!this.attrs)return"";var t=this.getAttrs(),e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r+'="'+t[r]+'"');return e.join(" ")}}),t.RegexLib=function(){var t="A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢴऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛱ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞭꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",e="0-9٠-٩۰-۹߀-߉०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯෦-෯๐-๙໐-໙༠-༩၀-၉႐-႙០-៩᠐-᠙᥆-᥏᧐-᧙᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙꘠-꘩꣐-꣙꤀-꤉꧐-꧙꧰-꧹꩐-꩙꯰-꯹0-9",r=t+e,n=new RegExp("["+r+".\\-]*["+r+"\\-]"),s=/(?:international|construction|contractors|enterprises|photography|productions|foundation|immobilien|industries|management|properties|technology|christmas|community|directory|education|equipment|institute|marketing|solutions|vacations|bargains|boutique|builders|catering|cleaning|clothing|computer|democrat|diamonds|graphics|holdings|lighting|partners|plumbing|supplies|training|ventures|academy|careers|company|cruises|domains|exposed|flights|florist|gallery|guitars|holiday|kitchen|neustar|okinawa|recipes|rentals|reviews|shiksha|singles|support|systems|agency|berlin|camera|center|coffee|condos|dating|estate|events|expert|futbol|kaufen|luxury|maison|monash|museum|nagoya|photos|repair|report|social|supply|tattoo|tienda|travel|viajes|villas|vision|voting|voyage|actor|build|cards|cheap|codes|dance|email|glass|house|mango|ninja|parts|photo|press|shoes|solar|today|tokyo|tools|watch|works|aero|arpa|asia|best|bike|blue|buzz|camp|club|cool|coop|farm|fish|gift|guru|info|jobs|kiwi|kred|land|limo|link|menu|mobi|moda|name|pics|pink|post|qpon|rich|ruhr|sexy|tips|vote|voto|wang|wien|wiki|zone|bar|bid|biz|cab|cat|ceo|com|edu|gov|int|kim|mil|net|onl|org|pro|pub|red|tel|uno|wed|xxx|xyz|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)\b/;return{alphaNumericCharsStr:r,domainNameRegex:n,tldRegex:s}}(),t.AnchorTagBuilder=t.Util.extend(Object,{constructor:function(e){t.Util.assign(this,e)},build:function(e){return new t.HtmlTag({tagName:"a",attrs:this.createAttrs(e.getType(),e.getAnchorHref()),innerHtml:this.processAnchorText(e.getAnchorText())})},createAttrs:function(t,e){var r={href:e},n=this.createCssClass(t);return n&&(r["class"]=n),this.newWindow&&(r.target="_blank"),r},createCssClass:function(t){var e=this.className;return e?e+" "+e+"-"+t:""},processAnchorText:function(t){return t=this.doTruncate(t)},doTruncate:function(e){var r=this.truncate;if(!r)return e;var n=r.length,s=r.location;return"smart"===s?t.truncate.TruncateSmart(e,n,".."):"middle"===s?t.truncate.TruncateMiddle(e,n,".."):t.truncate.TruncateEnd(e,n,"..")}}),t.htmlParser.HtmlParser=t.Util.extend(Object,{htmlRegex:function(){var t=/!--([\s\S]+?)--/,e=/[0-9a-zA-Z][0-9a-zA-Z:]*/,r=/[^\s\0"'>\/=\x01-\x1F\x7F]+/,n=/(?:"[^"]*?"|'[^']*?'|[^'"=<>`\s]+)/,s=r.source+"(?:\\s*=\\s*"+n.source+")?";return new RegExp(["(?:","<(!DOCTYPE)","(?:","\\s+","(?:",s,"|",n.source+")",")*",">",")","|","(?:","<(/)?","(?:",t.source,"|","(?:","("+e.source+")","(?:","\\s*",s,")*","\\s*/?",")",")",">",")"].join(""),"gi")}(),htmlCharacterEntitiesRegex:/(&nbsp;|&#160;|&lt;|&#60;|&gt;|&#62;|&quot;|&#34;|&#39;)/gi,parse:function(t){for(var e,r,n=this.htmlRegex,s=0,i=[];null!==(e=n.exec(t));){var a=e[0],o=e[3],h=e[1]||e[4],c=!!e[2],u=e.index,l=t.substring(s,u);l&&(r=this.parseTextAndEntityNodes(s,l),i.push.apply(i,r)),o?i.push(this.createCommentNode(u,a,o)):i.push(this.createElementNode(u,a,h,c)),s=u+a.length}if(s<t.length){var g=t.substring(s);g&&(r=this.parseTextAndEntityNodes(s,g),i.push.apply(i,r))}return i},parseTextAndEntityNodes:function(e,r){for(var n=[],s=t.Util.splitAndCapture(r,this.htmlCharacterEntitiesRegex),i=0,a=s.length;a>i;i+=2){var o=s[i],h=s[i+1];o&&(n.push(this.createTextNode(e,o)),e+=o.length),h&&(n.push(this.createEntityNode(e,h)),e+=h.length)}return n},createCommentNode:function(e,r,n){return new t.htmlParser.CommentNode({offset:e,text:r,comment:t.Util.trim(n)})},createElementNode:function(e,r,n,s){return new t.htmlParser.ElementNode({offset:e,text:r,tagName:n.toLowerCase(),closing:s})},createEntityNode:function(e,r){return new t.htmlParser.EntityNode({offset:e,text:r})},createTextNode:function(e,r){return new t.htmlParser.TextNode({offset:e,text:r})}}),t.htmlParser.HtmlNode=t.Util.extend(Object,{offset:void 0,text:void 0,constructor:function(e){t.Util.assign(this,e)},getType:t.Util.abstractMethod,getOffset:function(){return this.offset},getText:function(){return this.text}}),t.htmlParser.CommentNode=t.Util.extend(t.htmlParser.HtmlNode,{comment:"",getType:function(){return"comment"},getComment:function(){return this.comment}}),t.htmlParser.ElementNode=t.Util.extend(t.htmlParser.HtmlNode,{tagName:"",closing:!1,getType:function(){return"element"},getTagName:function(){return this.tagName},isClosing:function(){return this.closing}}),t.htmlParser.EntityNode=t.Util.extend(t.htmlParser.HtmlNode,{getType:function(){return"entity"}}),t.htmlParser.TextNode=t.Util.extend(t.htmlParser.HtmlNode,{getType:function(){return"text"}}),t.match.Match=t.Util.extend(Object,{constructor:function(t,e){this.matchedText=t,this.offset=e},getType:t.Util.abstractMethod,getMatchedText:function(){return this.matchedText},setOffset:function(t){this.offset=t},getOffset:function(){return this.offset},getAnchorHref:t.Util.abstractMethod,getAnchorText:t.Util.abstractMethod}),t.match.Email=t.Util.extend(t.match.Match,{constructor:function(e,r,n){t.match.Match.prototype.constructor.call(this,e,r),this.email=n},getType:function(){return"email"},getEmail:function(){return this.email},getAnchorHref:function(){return"mailto:"+this.email},getAnchorText:function(){return this.email}}),t.match.Hashtag=t.Util.extend(t.match.Match,{constructor:function(e,r,n,s){t.match.Match.prototype.constructor.call(this,e,r),this.serviceName=n,this.hashtag=s},getType:function(){return"hashtag"},getServiceName:function(){return this.serviceName},getHashtag:function(){return this.hashtag},getAnchorHref:function(){var t=this.serviceName,e=this.hashtag;switch(t){case"twitter":return"https://twitter.com/hashtag/"+e;case"facebook":return"https://www.facebook.com/hashtag/"+e;case"instagram":return"https://instagram.com/explore/tags/"+e;default:throw new Error("Unknown service name to point hashtag to: ",t)}},getAnchorText:function(){return"#"+this.hashtag}}),t.match.Phone=t.Util.extend(t.match.Match,{constructor:function(e,r,n,s){t.match.Match.prototype.constructor.call(this,e,r),this.number=n,this.plusSign=s},getType:function(){return"phone"},getNumber:function(){return this.number},getAnchorHref:function(){return"tel:"+(this.plusSign?"+":"")+this.number},getAnchorText:function(){return this.matchedText}}),t.match.Twitter=t.Util.extend(t.match.Match,{constructor:function(e,r,n){t.match.Match.prototype.constructor.call(this,e,r),this.twitterHandle=n},getType:function(){return"twitter"},getTwitterHandle:function(){return this.twitterHandle},getAnchorHref:function(){return"https://twitter.com/"+this.twitterHandle},getAnchorText:function(){return"@"+this.twitterHandle}}),t.match.Url=t.Util.extend(t.match.Match,{constructor:function(e,r,n,s,i,a,o){t.match.Match.prototype.constructor.call(this,e,r),this.urlMatchType=s,this.url=n,this.protocolUrlMatch=i,this.protocolRelativeMatch=a,this.stripPrefix=o},urlPrefixRegex:/^(https?:\/\/)?(www\.)?/i,protocolRelativeRegex:/^\/\//,protocolPrepended:!1,getType:function(){return"url"},getUrlMatchType:function(){return this.urlMatchType},getUrl:function(){var t=this.url;return this.protocolRelativeMatch||this.protocolUrlMatch||this.protocolPrepended||(t=this.url="http://"+t,this.protocolPrepended=!0),t},getAnchorHref:function(){var t=this.getUrl();return t.replace(/&amp;/g,"&")},getAnchorText:function(){var t=this.getMatchedText();return this.protocolRelativeMatch&&(t=this.stripProtocolRelativePrefix(t)),this.stripPrefix&&(t=this.stripUrlPrefix(t)),t=this.removeTrailingSlash(t)},stripUrlPrefix:function(t){return t.replace(this.urlPrefixRegex,"")},stripProtocolRelativePrefix:function(t){return t.replace(this.protocolRelativeRegex,"")},removeTrailingSlash:function(t){return"/"===t.charAt(t.length-1)&&(t=t.slice(0,-1)),t}}),t.matcher.Matcher=t.Util.extend(Object,{constructor:function(e){t.Util.assign(this,e)},parseMatches:t.Util.abstractMethod}),t.matcher.Email=t.Util.extend(t.matcher.Matcher,{matcherRegex:function(){var e=t.RegexLib.alphaNumericCharsStr,r=new RegExp("["+e+"\\-;:&=+$.,]+@"),n=t.RegexLib.domainNameRegex,s=t.RegexLib.tldRegex;return new RegExp([r.source,n.source,"\\.",s.source].join(""),"gi")}(),parseMatches:function(e){for(var r,n=this.matcherRegex,s=[];null!==(r=n.exec(e));){var i=r[0];s.push(new t.match.Email(i,r.index,i))}return s}}),t.matcher.Hashtag=t.Util.extend(t.matcher.Matcher,{matcherRegex:new RegExp("#[_"+t.RegexLib.alphaNumericCharsStr+"]{1,139}","g"),nonWordCharRegex:new RegExp("[^"+t.RegexLib.alphaNumericCharsStr+"]"),parseMatches:function(e){for(var r,n=this.matcherRegex,s=this.nonWordCharRegex,i=this.serviceName,a=[];null!==(r=n.exec(e));){var o=r.index,h=e.charAt(o-1);if(0===o||s.test(h)){var c=r[0],u=r[0].slice(1);a.push(new t.match.Hashtag(c,o,i,u))}}return a}}),t.matcher.Phone=t.Util.extend(t.matcher.Matcher,{matcherRegex:/(?:(\+)?\d{1,3}[-\040.])?\(?\d{3}\)?[-\040.]?\d{3}[-\040.]\d{4}/g,parseMatches:function(e){for(var r,n=this.matcherRegex,s=[];null!==(r=n.exec(e));){var i=r[0],a=i.replace(/\D/g,""),o=!!r[1];s.push(new t.match.Phone(i,r.index,a,o))}return s}}),t.matcher.Twitter=t.Util.extend(t.matcher.Matcher,{matcherRegex:new RegExp("@[_"+t.RegexLib.alphaNumericCharsStr+"]{1,20}","g"),nonWordCharRegex:new RegExp("[^"+t.RegexLib.alphaNumericCharsStr+"]"),parseMatches:function(e){for(var r,n=this.matcherRegex,s=this.nonWordCharRegex,i=[];null!==(r=n.exec(e));){var a=r.index,o=e.charAt(a-1);if(0===a||s.test(o)){var h=r[0],c=r[0].slice(1);i.push(new t.match.Twitter(h,a,c))}}return i}}),t.matcher.Url=t.Util.extend(t.matcher.Matcher,{matcherRegex:function(){var e=/(?:[A-Za-z][-.+A-Za-z0-9]*:(?![A-Za-z][-.+A-Za-z0-9]*:\/\/)(?!\d+\/?)(?:\/\/)?)/,r=/(?:www\.)/,n=t.RegexLib.domainNameRegex,s=t.RegexLib.tldRegex,i=t.RegexLib.alphaNumericCharsStr,a=new RegExp("["+i+"\\-+&@#/%=~_()|'$*\\[\\]?!:,.;]*["+i+"\\-+&@#/%=~_()|'$*\\[\\]]");return new RegExp(["(?:","(",e.source,n.source,")","|","(","(//)?",r.source,n.source,")","|","(","(//)?",n.source+"\\.",s.source,")",")","(?:"+a.source+")?"].join(""),"gi")}(),wordCharRegExp:/\w/,openParensRe:/\(/g,closeParensRe:/\)/g,parseMatches:function(e){for(var r,n=this.matcherRegex,s=this.stripPrefix,i=[];null!==(r=n.exec(e));){var a=r[0],o=r[1],h=r[2],c=r[3],u=r[5],l=r.index,g=c||u,f=e.charAt(l-1);if(t.matcher.UrlMatchValidator.isValid(a,o)&&!(l>0&&"@"===f||l>0&&g&&this.wordCharRegExp.test(f))){if(this.matchHasUnbalancedClosingParen(a))a=a.substr(0,a.length-1);else{var m=this.matchHasInvalidCharAfterTld(a,o);m>-1&&(a=a.substr(0,m))}var p=o?"scheme":h?"www":"tld",d=!!o;i.push(new t.match.Url(a,l,a,p,d,!!g,s))}}return i},matchHasUnbalancedClosingParen:function(t){var e=t.charAt(t.length-1);if(")"===e){var r=t.match(this.openParensRe),n=t.match(this.closeParensRe),s=r&&r.length||0,i=n&&n.length||0;if(i>s)return!0}return!1},matchHasInvalidCharAfterTld:function(t,e){if(!t)return-1;var r=0;e&&(r=t.indexOf(":"),t=t.slice(r));var n=/^((.?\/\/)?[A-Za-z0-9\u00C0-\u017F\.\-]*[A-Za-z0-9\u00C0-\u017F\-]\.[A-Za-z]+)/,s=n.exec(t);return null===s?-1:(r+=s[1].length,t=t.slice(s[1].length),/^[^.A-Za-z:\/?#]/.test(t)?r:-1)}}),t.matcher.UrlMatchValidator={hasFullProtocolRegex:/^[A-Za-z][-.+A-Za-z0-9]*:\/\//,uriSchemeRegex:/^[A-Za-z][-.+A-Za-z0-9]*:/,hasWordCharAfterProtocolRegex:/:[^\s]*?[A-Za-z\u00C0-\u017F]/,isValid:function(t,e){return!(e&&!this.isValidUriScheme(e)||this.urlMatchDoesNotHaveProtocolOrDot(t,e)||this.urlMatchDoesNotHaveAtLeastOneWordChar(t,e))},isValidUriScheme:function(t){var e=t.match(this.uriSchemeRegex)[0].toLowerCase();return"javascript:"!==e&&"vbscript:"!==e},urlMatchDoesNotHaveProtocolOrDot:function(t,e){return!(!t||e&&this.hasFullProtocolRegex.test(e)||-1!==t.indexOf("."))},urlMatchDoesNotHaveAtLeastOneWordChar:function(t,e){return t&&e?!this.hasWordCharAfterProtocolRegex.test(t):!1}},t.truncate.TruncateEnd=function(e,r,n){return t.Util.ellipsis(e,r,n)},t.truncate.TruncateMiddle=function(t,e,r){if(t.length<=e)return t;var n=e-r.length,s="";return n>0&&(s=t.substr(-1*Math.floor(n/2))),(t.substr(0,Math.ceil(n/2))+r+s).substr(0,e)},t.truncate.TruncateSmart=function(t,e,r){var n=function(t){var e={},r=t,n=r.match(/^([a-z]+):\/\//i);return n&&(e.scheme=n[1],r=r.substr(n[0].length)),n=r.match(/^(.*?)(?=(\?|#|\/|$))/i),n&&(e.host=n[1],r=r.substr(n[0].length)),n=r.match(/^\/(.*?)(?=(\?|#|$))/i),n&&(e.path=n[1],r=r.substr(n[0].length)),n=r.match(/^\?(.*?)(?=(#|$))/i),n&&(e.query=n[1],r=r.substr(n[0].length)),n=r.match(/^#(.*?)$/i),n&&(e.fragment=n[1]),e},s=function(t){var e="";return t.scheme&&t.host&&(e+=t.scheme+"://"),t.host&&(e+=t.host),t.path&&(e+="/"+t.path),t.query&&(e+="?"+t.query),t.fragment&&(e+="#"+t.fragment),e},i=function(t,e){var n=e/2,s=Math.ceil(n),i=-1*Math.floor(n),a="";return 0>i&&(a=t.substr(i)),t.substr(0,s)+r+a};if(t.length<=e)return t;var a=e-r.length,o=n(t);if(o.query){var h=o.query.match(/^(.*?)(?=(\?|\#))(.*?)$/i);h&&(o.query=o.query.substr(0,h[1].length),t=s(o))}if(t.length<=e)return t;if(o.host&&(o.host=o.host.replace(/^www\./,""),t=s(o)),t.length<=e)return t;var c="";if(o.host&&(c+=o.host),c.length>=a)return o.host.length==e?(o.host.substr(0,e-r.length)+r).substr(0,e):i(c,a).substr(0,e);var u="";if(o.path&&(u+="/"+o.path),o.query&&(u+="?"+o.query),u){if((c+u).length>=a){if((c+u).length==e)return(c+u).substr(0,e);var l=a-c.length;return(c+i(u,l)).substr(0,e)}c+=u}if(o.fragment){var g="#"+o.fragment;if((c+g).length>=a){if((c+g).length==e)return(c+g).substr(0,e);var f=a-c.length;return(c+i(g,f)).substr(0,e)}c+=g}if(o.scheme&&o.host){var m=o.scheme+"://";if((c+m).length<a)return(m+c).substr(0,e)}if(c.length<=e)return c;var p="";return a>0&&(p=c.substr(-1*Math.floor(a/2))),(c.substr(0,Math.ceil(a/2))+r+p).substr(0,e)},t});
{
"name": "autolinker",
"version": "0.24.0",
"version": "0.24.1",
"description": "Utility to automatically link the URLs, email addresses, and Twitter handles in a given block of text/HTML",

@@ -13,3 +13,3 @@ "main": "dist/Autolinker.js",

"scripts": {
"test": "grunt"
"test": "gulp"
},

@@ -35,14 +35,26 @@ "repository": {

"devDependencies": {
"grunt": "^0.4.4",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-jasmine": "^0.9.2",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-uglify": "^0.4.0",
"grunt-jsduck": "^1.0.1",
"grunt-preprocess": "^4.1.0",
"grunt-umd": "^2.0.1",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.0",
"gulp-connect": "^3.0.0",
"gulp-jasmine": "^2.3.0",
"gulp-jsduck": "^0.3.0",
"gulp-jshint": "^2.0.0",
"gulp-preprocess": "^2.0.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.3",
"gulp-umd": "^0.2.0",
"jasmine-core": "^2.4.1",
"jshint": "^2.9.1",
"jshint-stylish": "^2.1.0",
"karma": "^0.13.21",
"karma-jasmine": "^0.3.7",
"karma-phantomjs-launcher": "^1.0.0",
"karma-spec-reporter": "0.0.24",
"lodash": "^4.3.0",
"phantomjs-prebuilt": "^2.1.4",
"requirejs": "^2.1.11"
},
"dependencies": {
"gulp-header": "^1.7.1"
}
}

@@ -1,4 +0,1 @@

If you love and use Autolinker, please consider a $5 donation to support continued development. Many, many hours have gone into this project, and I hope it's helping you out! <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9HX848RTS975Y&lc=US&item_name=Autolinker%2ejs%20Donation&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted" target="_blank"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" alt="Preview Image"></a>
# Autolinker.js

@@ -322,3 +319,3 @@

- Make sure to add tests to cover your new functionality/bugfix.
- Run the `grunt` command to build/test (or alternatively, open the `tests/index.html` file to run the tests).
- Run the `gulp` command to build/test (or alternatively, open the `tests/index.html` file to run the tests).
- When committing, please omit checking in the files in the `dist/` folder after building/testing. These are only committed to the repository for users downloading Autolinker via Bower. I will build these files and assign them a version number when merging your PR.

@@ -325,0 +322,0 @@ - Please use tabs for indents! Tabs are better for everybody (individuals can set their editors to different tab sizes based on their visual preferences).

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc