Socket
Socket
Sign inDemoInstall

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.16.0 to 0.17.0

src/match/Hashtag.js

4

dist/Autolinker.min.js
/*!
* Autolinker.js
* 0.16.0
* 0.17.0
*

@@ -10,2 +10,2 @@ * Copyright(c) 2015 Gregory Jacobs <greg@greg-jacobs.com>

*/
!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(b){a.Util.assign(this,b)};return a.prototype={constructor:a,urls:!0,email:!0,twitter:!0,phone:!0,newWindow:!0,stripPrefix:!0,truncate:void 0,className:"",htmlParser:void 0,matchParser:void 0,tagBuilder:void 0,link: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(),j=h.getText();if("element"===i)"a"===h.getTagName()&&(h.isClosing()?d=Math.max(d-1,0):d++),e.push(j);else if("entity"===i)e.push(j);else if(0===d){var k=this.linkifyStr(j);e.push(k)}else e.push(j)}return e.join("")},linkifyStr:function(a){return this.getMatchParser().replace(a,this.createMatchReturnVal,this)},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},getMatchParser:function(){var b=this.matchParser;return b||(b=this.matchParser=new a.matchParser.MatchParser({urls:this.urls,email:this.email,twitter:this.twitter,phone:this.phone,stripPrefix:this.stripPrefix})),b},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.htmlParser={},a.matchParser={},a.Util={abstractMethod:function(){throw"abstract"},assign:function(a,b){for(var c in b)b.hasOwnProperty(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}},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.AnchorTagBuilder=a.Util.extend(Object,{constructor:function(b){a.Util.assign(this,b)},build:function(b){var c=new a.HtmlTag({tagName:"a",attrs:this.createAttrs(b.getType(),b.getAnchorHref()),innerHtml:this.processAnchorText(b.getAnchorText())});return c},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){return a.Util.ellipsis(b,this.truncate||Number.POSITIVE_INFINITY)}}),a.htmlParser.HtmlParser=a.Util.extend(Object,{htmlRegex:function(){var a=/[0-9a-zA-Z][0-9a-zA-Z:]*/,b=/[^\s\0"'>\/=\x01-\x1F\x7F]+/,c=/(?:"[^"]*?"|'[^']*?'|[^'"=<>`\s]+)/,d=b.source+"(?:\\s*=\\s*"+c.source+")?";return new RegExp(["(?:","<(!DOCTYPE)","(?:","\\s+","(?:",d,"|",c.source+")",")*",">",")","|","(?:","<(/)?","("+a.source+")","(?:","\\s+",d,")*","\\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[1]||b[3],i=!!b[2],j=a.substring(e,b.index);j&&(c=this.parseTextAndEntityNodes(j),f.push.apply(f,c)),f.push(this.createElementNode(g,h,i)),e=b.index+g.length}if(e<a.length){var k=a.substring(e);k&&(c=this.parseTextAndEntityNodes(k),f.push.apply(f,c))}return f},parseTextAndEntityNodes:function(b){for(var c=[],d=a.Util.splitAndCapture(b,this.htmlCharacterEntitiesRegex),e=0,f=d.length;f>e;e+=2){var g=d[e],h=d[e+1];g&&c.push(this.createTextNode(g)),h&&c.push(this.createEntityNode(h))}return c},createElementNode:function(b,c,d){return new a.htmlParser.ElementNode({text:b,tagName:c.toLowerCase(),closing:d})},createEntityNode:function(b){return new a.htmlParser.EntityNode({text:b})},createTextNode:function(b){return new a.htmlParser.TextNode({text:b})}}),a.htmlParser.HtmlNode=a.Util.extend(Object,{text:"",constructor:function(b){a.Util.assign(this,b)},getType:a.Util.abstractMethod,getText:function(){return this.text}}),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.matchParser.MatchParser=a.Util.extend(Object,{urls:!0,email:!0,twitter:!0,phone:!0,stripPrefix:!0,matcherRegex:function(){var a=/(^|[^\w])@(\w{1,15})/,b=/(?:[\-;:&=\+\$,\w\.]+@)/,c=/(?:\+?\d{1,3}[-\s.])?\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/,d=/(?:[A-Za-z][-.+A-Za-z0-9]+:(?![A-Za-z][-.+A-Za-z0-9]+:\/\/)(?!\d+\/?)(?:\/\/)?)/,e=/(?:www\.)/,f=/[A-Za-z0-9\.\-]*[A-Za-z0-9\-]/,g=/\.(?: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|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/,h=/[\-A-Za-z0-9+&@#\/%=~_()|'$*\[\]?!:,.;]*[\-A-Za-z0-9+&@#\/%=~_()|'$*\[\]]/;return new RegExp(["(",a.source,")","|","(",b.source,f.source,g.source,")","|","(","(?:","(",d.source,f.source,")","|","(?:","(.?//)?",e.source,f.source,")","|","(?:","(.?//)?",f.source,g.source,")",")","(?:"+h.source+")?",")","|","(",c.source,")"].join(""),"gi")}(),charBeforeProtocolRelMatchRegex:/^(.)?\/\//,constructor:function(b){a.Util.assign(this,b),this.matchValidator=new a.MatchValidator},replace:function(a,b,c){var d=this;return a.replace(this.matcherRegex,function(a,e,f,g,h,i,j,k,l,m){var n=d.processCandidateMatch(a,e,f,g,h,i,j,k,l,m);if(n){var o=b.call(c,n.match);return n.prefixStr+o+n.suffixStr}return a})},processCandidateMatch:function(b,c,d,e,f,g,h,i,j,k){var l,m=i||j,n="",o="";if(c&&!this.twitter||f&&!this.email||g&&!this.urls||k&&!this.phone||!this.matchValidator.isValidMatch(g,h,m))return null;if(this.matchHasUnbalancedClosingParen(b)&&(b=b.substr(0,b.length-1),o=")"),f)l=new a.match.Email({matchedText:b,email:f});else if(c)d&&(n=d,b=b.slice(1)),l=new a.match.Twitter({matchedText:b,twitterHandle:e});else if(k){var p=b.replace(/\D/g,"");l=new a.match.Phone({matchedText:b,number:p})}else{if(m){var q=m.match(this.charBeforeProtocolRelMatchRegex)[1]||"";q&&(n=q,b=b.slice(1))}l=new a.match.Url({matchedText:b,url:b,protocolUrlMatch:!!h,protocolRelativeMatch:!!m,stripPrefix:this.stripPrefix})}return{prefixStr:n,suffixStr:o,match:l}},matchHasUnbalancedClosingParen:function(a){var b=a.charAt(a.length-1);if(")"===b){var c=a.match(/\(/g),d=a.match(/\)/g),e=c&&c.length||0,f=d&&d.length||0;if(f>e)return!0}return!1}}),a.MatchValidator=a.Util.extend(Object,{invalidProtocolRelMatchRegex:/^[\w]\/\//,hasFullProtocolRegex:/^[A-Za-z][-.+A-Za-z0-9]+:\/\//,uriSchemeRegex:/^[A-Za-z][-.+A-Za-z0-9]+:/,hasWordCharAfterProtocolRegex:/:[^\s]*?[A-Za-z]/,isValidMatch:function(a,b,c){return b&&!this.isValidUriScheme(b)||this.urlMatchDoesNotHaveProtocolOrDot(a,b)||this.urlMatchDoesNotHaveAtLeastOneWordChar(a,b)||this.isInvalidProtocolRelativeMatch(c)?!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},isInvalidProtocolRelativeMatch:function(a){return!!a&&this.invalidProtocolRelMatchRegex.test(a)}}),a.match.Match=a.Util.extend(Object,{constructor:function(b){a.Util.assign(this,b)},getType:a.Util.abstractMethod,getMatchedText:function(){return this.matchedText},getAnchorHref:a.Util.abstractMethod,getAnchorText:a.Util.abstractMethod}),a.match.Email=a.Util.extend(a.match.Match,{getType:function(){return"email"},getEmail:function(){return this.email},getAnchorHref:function(){return"mailto:"+this.email},getAnchorText:function(){return this.email}}),a.match.Phone=a.Util.extend(a.match.Match,{getType:function(){return"phone"},getNumber:function(){return this.number},getAnchorHref:function(){return"tel:"+this.number},getAnchorText:function(){return this.matchedText}}),a.match.Twitter=a.Util.extend(a.match.Match,{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,{urlPrefixRegex:/^(https?:\/\/)?(www\.)?/i,protocolRelativeRegex:/^\/\//,protocolPrepended:!1,getType:function(){return"url"},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.getUrl();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});
!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(b){a.Util.assign(this,b);var c=this.hashtag;if(c!==!1&&"twitter"!==c&&"facebook"!==c)throw new Error("invalid `hashtag` cfg - see docs")};return a.prototype={constructor:a,urls:!0,email:!0,twitter:!0,phone:!0,hashtag:!1,newWindow:!0,stripPrefix:!0,truncate:void 0,className:"",htmlParser:void 0,matchParser:void 0,tagBuilder:void 0,link: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(),j=h.getText();if("element"===i)"a"===h.getTagName()&&(h.isClosing()?d=Math.max(d-1,0):d++),e.push(j);else if("entity"===i)e.push(j);else if(0===d){var k=this.linkifyStr(j);e.push(k)}else e.push(j)}return e.join("")},linkifyStr:function(a){return this.getMatchParser().replace(a,this.createMatchReturnVal,this)},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},getMatchParser:function(){var b=this.matchParser;return b||(b=this.matchParser=new a.matchParser.MatchParser({urls:this.urls,email:this.email,twitter:this.twitter,phone:this.phone,hashtag:this.hashtag,stripPrefix:this.stripPrefix})),b},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.htmlParser={},a.matchParser={},a.Util={abstractMethod:function(){throw"abstract"},assign:function(a,b){for(var c in b)b.hasOwnProperty(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}},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.AnchorTagBuilder=a.Util.extend(Object,{constructor:function(b){a.Util.assign(this,b)},build:function(b){var c=new a.HtmlTag({tagName:"a",attrs:this.createAttrs(b.getType(),b.getAnchorHref()),innerHtml:this.processAnchorText(b.getAnchorText())});return c},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){return a.Util.ellipsis(b,this.truncate||Number.POSITIVE_INFINITY)}}),a.htmlParser.HtmlParser=a.Util.extend(Object,{htmlRegex:function(){var a=/[0-9a-zA-Z][0-9a-zA-Z:]*/,b=/[^\s\0"'>\/=\x01-\x1F\x7F]+/,c=/(?:"[^"]*?"|'[^']*?'|[^'"=<>`\s]+)/,d=b.source+"(?:\\s*=\\s*"+c.source+")?";return new RegExp(["(?:","<(!DOCTYPE)","(?:","\\s+","(?:",d,"|",c.source+")",")*",">",")","|","(?:","<(/)?","("+a.source+")","(?:","\\s+",d,")*","\\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[1]||b[3],i=!!b[2],j=a.substring(e,b.index);j&&(c=this.parseTextAndEntityNodes(j),f.push.apply(f,c)),f.push(this.createElementNode(g,h,i)),e=b.index+g.length}if(e<a.length){var k=a.substring(e);k&&(c=this.parseTextAndEntityNodes(k),f.push.apply(f,c))}return f},parseTextAndEntityNodes:function(b){for(var c=[],d=a.Util.splitAndCapture(b,this.htmlCharacterEntitiesRegex),e=0,f=d.length;f>e;e+=2){var g=d[e],h=d[e+1];g&&c.push(this.createTextNode(g)),h&&c.push(this.createEntityNode(h))}return c},createElementNode:function(b,c,d){return new a.htmlParser.ElementNode({text:b,tagName:c.toLowerCase(),closing:d})},createEntityNode:function(b){return new a.htmlParser.EntityNode({text:b})},createTextNode:function(b){return new a.htmlParser.TextNode({text:b})}}),a.htmlParser.HtmlNode=a.Util.extend(Object,{text:"",constructor:function(b){a.Util.assign(this,b)},getType:a.Util.abstractMethod,getText:function(){return this.text}}),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.matchParser.MatchParser=a.Util.extend(Object,{urls:!0,email:!0,twitter:!0,phone:!0,hashtag:!1,stripPrefix:!0,matcherRegex:function(){var a=/(^|[^\w])@(\w{1,15})/,b=/(^|[^\w])#(\w{1,15})/,c=/(?:[\-;:&=\+\$,\w\.]+@)/,d=/(?:\+?\d{1,3}[-\s.])?\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/,e=/(?:[A-Za-z][-.+A-Za-z0-9]+:(?![A-Za-z][-.+A-Za-z0-9]+:\/\/)(?!\d+\/?)(?:\/\/)?)/,f=/(?:www\.)/,g=/[A-Za-z0-9\.\-]*[A-Za-z0-9\-]/,h=/\.(?: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|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/,i=/[\-A-Za-z0-9+&@#\/%=~_()|'$*\[\]?!:,.;]*[\-A-Za-z0-9+&@#\/%=~_()|'$*\[\]]/;return new RegExp(["(",a.source,")","|","(",c.source,g.source,h.source,")","|","(","(?:","(",e.source,g.source,")","|","(?:","(.?//)?",f.source,g.source,")","|","(?:","(.?//)?",g.source,h.source,")",")","(?:"+i.source+")?",")","|","(",d.source,")","|","(",b.source,")"].join(""),"gi")}(),charBeforeProtocolRelMatchRegex:/^(.)?\/\//,constructor:function(b){a.Util.assign(this,b),this.matchValidator=new a.MatchValidator},replace:function(a,b,c){var d=this;return a.replace(this.matcherRegex,function(a,e,f,g,h,i,j,k,l,m,n,o,p){var q=d.processCandidateMatch(a,e,f,g,h,i,j,k,l,m,n,o,p);if(q){var r=b.call(c,q.match);return q.prefixStr+r+q.suffixStr}return a})},processCandidateMatch:function(b,c,d,e,f,g,h,i,j,k,l,m,n){var o,p=i||j,q="",r="";if(g&&!this.urls||f&&!this.email||k&&!this.phone||c&&!this.twitter||l&&!this.hashtag||!this.matchValidator.isValidMatch(g,h,p))return null;if(this.matchHasUnbalancedClosingParen(b)&&(b=b.substr(0,b.length-1),r=")"),f)o=new a.match.Email({matchedText:b,email:f});else if(c)d&&(q=d,b=b.slice(1)),o=new a.match.Twitter({matchedText:b,twitterHandle:e});else if(k){var s=b.replace(/\D/g,"");o=new a.match.Phone({matchedText:b,number:s})}else if(l)m&&(q=m,b=b.slice(1)),o=new a.match.Hashtag({matchedText:b,serviceName:this.hashtag,hashtag:n});else{if(p){var t=p.match(this.charBeforeProtocolRelMatchRegex)[1]||"";t&&(q=t,b=b.slice(1))}o=new a.match.Url({matchedText:b,url:b,protocolUrlMatch:!!h,protocolRelativeMatch:!!p,stripPrefix:this.stripPrefix})}return{prefixStr:q,suffixStr:r,match:o}},matchHasUnbalancedClosingParen:function(a){var b=a.charAt(a.length-1);if(")"===b){var c=a.match(/\(/g),d=a.match(/\)/g),e=c&&c.length||0,f=d&&d.length||0;if(f>e)return!0}return!1}}),a.MatchValidator=a.Util.extend(Object,{invalidProtocolRelMatchRegex:/^[\w]\/\//,hasFullProtocolRegex:/^[A-Za-z][-.+A-Za-z0-9]+:\/\//,uriSchemeRegex:/^[A-Za-z][-.+A-Za-z0-9]+:/,hasWordCharAfterProtocolRegex:/:[^\s]*?[A-Za-z]/,isValidMatch:function(a,b,c){return b&&!this.isValidUriScheme(b)||this.urlMatchDoesNotHaveProtocolOrDot(a,b)||this.urlMatchDoesNotHaveAtLeastOneWordChar(a,b)||this.isInvalidProtocolRelativeMatch(c)?!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},isInvalidProtocolRelativeMatch:function(a){return!!a&&this.invalidProtocolRelMatchRegex.test(a)}}),a.match.Match=a.Util.extend(Object,{constructor:function(b){a.Util.assign(this,b)},getType:a.Util.abstractMethod,getMatchedText:function(){return this.matchedText},getAnchorHref:a.Util.abstractMethod,getAnchorText:a.Util.abstractMethod}),a.match.Email=a.Util.extend(a.match.Match,{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,{getType:function(){return"hashtag"},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;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,{getType:function(){return"phone"},getNumber:function(){return this.number},getAnchorHref:function(){return"tel:"+this.number},getAnchorText:function(){return this.matchedText}}),a.match.Twitter=a.Util.extend(a.match.Match,{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,{urlPrefixRegex:/^(https?:\/\/)?(www\.)?/i,protocolRelativeRegex:/^\/\//,protocolPrepended:!1,getType:function(){return"url"},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.getUrl();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});

@@ -68,2 +68,3 @@ /*global require, module */

'src/match/Email.js',
'src/match/Hashtag.js',
'src/match/Phone.js',

@@ -70,0 +71,0 @@ 'src/match/Twitter.js',

{
"name": "autolinker",
"version": "0.16.0",
"version": "0.17.0",
"description": "Utility to automatically link the URLs, email addresses, and Twitter handles in a given block of text/HTML",

@@ -5,0 +5,0 @@ "main": "dist/Autolinker.js",

@@ -18,2 +18,3 @@ # Autolinker.js

- Will autolink Twitter handles.
- Will autolink hashtags.
- Will properly handle HTML input. The utility will not change the `href`

@@ -99,11 +100,18 @@ attribute inside anchor (&lt;a&gt;) tags (or any other tag/attribute for that

- [newWindow](http://gregjacobs.github.io/Autolinker.js/docs/#!/api/Autolinker-cfg-newWindow) : Boolean<br />
`true` to have the links should open in a new window when clicked, `false` otherwise. Defaults to `true`.<br /><br />
`true` to have the links should open in a new window when clicked, `false`
otherwise. Defaults to `true`.<br /><br />
- [stripPrefix](http://gregjacobs.github.io/Autolinker.js/docs/#!/api/Autolinker-cfg-stripPrefix) : Boolean<br />
`true` to have the 'http://' or 'https://' and/or the 'www.' stripped from the beginning of links, `false` otherwise. Defaults to `true`.<br /><br />
`true` to have the 'http://' or 'https://' and/or the 'www.' stripped from the
beginning of links, `false` otherwise. Defaults to `true`.<br /><br />
- [truncate](http://gregjacobs.github.io/Autolinker.js/docs/#!/api/Autolinker-cfg-truncate) : Number<br />
A number for how many characters long URLs/emails/twitter handles should be truncated to inside the text of a link. If the URL/email/twitter is over the number of characters, it will be truncated to this length by replacing the end of the string with a two period ellipsis ('..').<br /><br />
Example: a url like 'http://www.yahoo.com/some/long/path/to/a/file' truncated to 25 characters may look like this: 'yahoo.com/some/long/pat..'<br /><br />
A number for how many characters long URLs/emails/Twitter handles/Twitter
hashtags should be truncated to inside the text of a link. If the match is
over the number of characters, it will be truncated to this length by
replacing the end of the string with a two period ellipsis ('..').<br /><br />
Example: a url like 'http://www.yahoo.com/some/long/path/to/a/file' truncated
to 25 characters may look like this: 'yahoo.com/some/long/pat..'<br /><br />
- [className](http://gregjacobs.github.io/Autolinker.js/docs/#!/api/Autolinker-cfg-className) : String<br />
A CSS class name to add to the generated anchor tags. This class will be added to all links, as well as this class
plus "url"/"email"/"twitter" suffixes for styling url/email/twitter links differently.
A CSS class name to add to the generated anchor tags. This class will be added
to all links, as well as this class plus "url"/"email"/"phone"/"twitter"/"hashtag"
suffixes for styling url/email/phone/twitter/hashtag links differently.

@@ -113,16 +121,28 @@ For example, if this config is provided as "myLink", then:

1) URL links will have the CSS classes: "myLink myLink-url"<br />
2) Email links will have the CSS classes: "myLink myLink-email", and<br />
3) Twitter links will have the CSS classes: "myLink myLink-twitter"<br />
2) Email links will have the CSS classes: "myLink myLink-email"<br />
3) Phone links will have the CSS classes: "myLink myLink-phone"<br />
4) Twitter links will have the CSS classes: "myLink myLink-twitter"<br />
5) Hashtag links will have the CSS classes: "myLink myLink-hashtag"<br />
- [urls](http://gregjacobs.github.io/Autolinker.js/docs/#!/api/Autolinker-cfg-urls) : Boolean<br />
`true` to have URLs auto-linked, `false` to skip auto-linking of URLs. Defaults to `true`.<br />
`true` to have URLs auto-linked, `false` to skip auto-linking of URLs.
Defaults to `true`.<br />
- [email](http://gregjacobs.github.io/Autolinker.js/docs/#!/api/Autolinker-cfg-email) : Boolean<br />
`true` to have email addresses auto-linked, `false` to skip auto-linking of email addresses. Defaults to `true`.<br /><br />
`true` to have email addresses auto-linked, `false` to skip auto-linking of
email addresses. Defaults to `true`.<br /><br />
- [phone](http://gregjacobs.github.io/Autolinker.js/docs/#!/api/Autolinker-cfg-phone) : Boolean<br />
`true` to have phone numbers auto-linked, `false` to skip auto-linking of phone numbers. Defaults to `true`.<br /><br />
`true` to have phone numbers auto-linked, `false` to skip auto-linking of
phone numbers. Defaults to `true`.<br /><br />
- [twitter](http://gregjacobs.github.io/Autolinker.js/docs/#!/api/Autolinker-cfg-twitter) : Boolean<br />
`true` to have Twitter handles auto-linked, `false` to skip auto-linking of Twitter handles. Defaults to `true`.<br /><br />
`true` to have Twitter handles auto-linked, `false` to skip auto-linking of
Twitter handles. Defaults to `true`.<br /><br />
- [hashtag](http://gregjacobs.github.io/Autolinker.js/docs/#!/api/Autolinker-cfg-hashtag) : Boolean/String<br />
A string for the service name to have hashtags auto-linked to. Supported
values at this time are 'twitter' and 'facebook'. Pass `false` to skip
auto-linking of hashtags. Defaults to `false`.<br /><br />
- [replaceFn](http://gregjacobs.github.io/Autolinker.js/docs/#!/api/Autolinker-cfg-replaceFn) : Function<br />
A function to use to programmatically make replacements of matches in the input string, one at a time. See the section
<a href="#custom-replacement-function">Custom Replacement Function</a> for more details.
A function to use to programmatically make replacements of matches in the
input string, one at a time. See the section
<a href="#custom-replacement-function">Custom Replacement Function</a> for
more details.

@@ -175,4 +195,4 @@

A custom replacement function ([replaceFn](http://gregjacobs.github.io/Autolinker.js/docs/#!/api/Autolinker-cfg-replaceFn))
may be provided to replace url/email/twitter matches on an individual basis,
based on the return from this function.
may be provided to replace url/email/phone/Twitter handle/hashtag matches on an
individual basis, based on the return from this function.

@@ -182,3 +202,3 @@ Full example, for purposes of documenting the API:

```javascript
var input = "..."; // string with URLs, Email Addresses, and Twitter Handles
var input = "..."; // string with URLs, Email Addresses, Twitter Handles, and Hashtags

@@ -217,5 +237,5 @@ var linkedText = Autolinker.link( input, {

var phoneNumber = match.getPhoneNumber();
console.log( twitterHandle );
console.log( phoneNumber );
return '<a href="http://newplace.to.link.twitter.handles.to/">' + twitterHandle + '</a>';
return '<a href="http://newplace.to.link.phone.numbers.to/">' + phoneNumber + '</a>';

@@ -227,2 +247,8 @@ case 'twitter' :

return '<a href="http://newplace.to.link.twitter.handles.to/">' + twitterHandle + '</a>';
case 'hashtag' :
var hashtag = match.getHashtag();
console.log( hashtag );
return '<a href="http://newplace.to.link.hashtag.handles.to/">' + hashtag + '</a>';
}

@@ -229,0 +255,0 @@ }

@@ -7,9 +7,9 @@ /*global Autolinker */

* @extends Object
*
*
* Builds anchor (&lt;a&gt;) tags for the Autolinker utility when a match is found.
*
* Normally this class is instantiated, configured, and used internally by an {@link Autolinker} instance, but may
*
* Normally this class is instantiated, configured, and used internally by an {@link Autolinker} instance, but may
* actually be retrieved in a {@link Autolinker#replaceFn replaceFn} to create {@link Autolinker.HtmlTag HtmlTag} instances
* which may be modified before returning from the {@link Autolinker#replaceFn replaceFn}. For example:
*
*
* var html = Autolinker.link( "Test google.com", {

@@ -19,7 +19,7 @@ * replaceFn : function( autolinker, match ) {

* tag.setAttr( 'rel', 'nofollow' );
*
*
* return tag;
* }
* } );
*
*
* // generated html:

@@ -29,3 +29,3 @@ * // Test <a href="http://google.com" target="_blank" rel="nofollow">google.com</a>

Autolinker.AnchorTagBuilder = Autolinker.Util.extend( Object, {
/**

@@ -35,3 +35,3 @@ * @cfg {Boolean} newWindow

*/
/**

@@ -41,3 +41,3 @@ * @cfg {Number} truncate

*/
/**

@@ -47,4 +47,4 @@ * @cfg {String} className

*/
/**

@@ -57,9 +57,10 @@ * @constructor

},
/**
* Generates the actual anchor (&lt;a&gt;) tag to use in place of the matched URL/email/Twitter text,
* via its `match` object.
*
* @param {Autolinker.match.Match} match The Match instance to generate an anchor tag from.
* Generates the actual anchor (&lt;a&gt;) tag to use in place of the
* matched text, via its `match` object.
*
* @param {Autolinker.match.Match} match The Match instance to generate an
* anchor tag from.
* @return {Autolinker.HtmlTag} The HtmlTag instance for the anchor tag.

@@ -73,14 +74,16 @@ */

} );
return tag;
},
/**
* Creates the Object (map) of the HTML attributes for the anchor (&lt;a&gt;) tag being generated.
*
* Creates the Object (map) of the HTML attributes for the anchor (&lt;a&gt;)
* tag being generated.
*
* @protected
* @param {"url"/"email"/"twitter"} matchType The type of match that an anchor tag is being generated for.
* @param {"url"/"email"/"phone"/"twitter"/"hashtag"} matchType The type of
* match that an anchor tag is being generated for.
* @param {String} href The href for the anchor tag.
* @return {Object} A key/value Object (map) of the anchor tag's attributes.
* @return {Object} A key/value Object (map) of the anchor tag's attributes.
*/

@@ -91,3 +94,3 @@ createAttrs : function( matchType, anchorHref ) {

};
var cssClass = this.createCssClass( matchType );

@@ -100,31 +103,35 @@ if( cssClass ) {

}
return attrs;
},
/**
* Creates the CSS class that will be used for a given anchor tag, based on the `matchType` and the {@link #className}
* config.
*
* Creates the CSS class that will be used for a given anchor tag, based on
* the `matchType` and the {@link #className} config.
*
* @private
* @param {"url"/"email"/"twitter"} matchType The type of match that an anchor tag is being generated for.
* @return {String} The CSS class string for the link. Example return: "myLink myLink-url". If no {@link #className}
* was configured, returns an empty string.
* @param {"url"/"email"/"phone"/"twitter"/"hashtag"} matchType The type of
* match that an anchor tag is being generated for.
* @return {String} The CSS class string for the link. Example return:
* "myLink myLink-url". If no {@link #className} was configured, returns
* an empty string.
*/
createCssClass : function( matchType ) {
var className = this.className;
if( !className )
if( !className )
return "";
else
return className + " " + className + "-" + matchType; // ex: "myLink myLink-url", "myLink myLink-email", or "myLink myLink-twitter"
return className + " " + className + "-" + matchType; // ex: "myLink myLink-url", "myLink myLink-email", "myLink myLink-phone", "myLink myLink-twitter", or "myLink myLink-hashtag"
},
/**
* Processes the `anchorText` by truncating the text according to the {@link #truncate} config.
*
* Processes the `anchorText` by truncating the text according to the
* {@link #truncate} config.
*
* @private
* @param {String} anchorText The anchor tag's text (i.e. what will be displayed).
* @param {String} anchorText The anchor tag's text (i.e. what will be
* displayed).
* @return {String} The processed `anchorText`.

@@ -134,11 +141,13 @@ */

anchorText = this.doTruncate( anchorText );
return anchorText;
},
/**
* Performs the truncation of the `anchorText`, if the `anchorText` is longer than the {@link #truncate} option.
* Truncates the text to 2 characters fewer than the {@link #truncate} option, and adds ".." to the end.
*
* Performs the truncation of the `anchorText`, if the `anchorText` is
* longer than the {@link #truncate} option. Truncates the text to 2
* characters fewer than the {@link #truncate} option, and adds ".." to the
* end.
*
* @private

@@ -151,3 +160,3 @@ * @param {String} text The anchor tag's text (i.e. what will be displayed).

}
} );

@@ -5,7 +5,8 @@ /**

*
* Utility class used to process a given string of text, and wrap the URLs, email addresses, phone #s, and Twitter handles in
* Utility class used to process a given string of text, and wrap the matches in
* the appropriate anchor (&lt;a&gt;) tags to turn them into links.
*
* Any of the configuration options may be provided in an Object (map) provided to the Autolinker constructor, which
* will configure how the {@link #link link()} method will process the links.
* Any of the configuration options may be provided in an Object (map) provided
* to the Autolinker constructor, which will configure how the {@link #link link()}
* method will process the links.
*

@@ -35,8 +36,10 @@ * For example:

*
* If the configuration options do not provide enough flexibility, a {@link #replaceFn} may be provided to fully customize
* the output of Autolinker. This function is called once for each URL/Email/Phone#/Twitter handle match that is encountered.
* If the configuration options do not provide enough flexibility, a {@link #replaceFn}
* may be provided to fully customize the output of Autolinker. This function is
* called once for each URL/Email/Phone#/Twitter Handle/Hashtag match that is
* encountered.
*
* For example:
*
* var input = "..."; // string with URLs, Email Addresses, Phone #s, and Twitter Handles
* var input = "..."; // string with URLs, Email Addresses, Phone #s, Twitter Handles, and Hashtags
*

@@ -73,2 +76,8 @@ * var linkedText = Autolinker.link( input, {

*
* case 'phone' :
* var phoneNumber = match.getPhoneNumber();
* console.log( phoneNumber );
*
* return '<a href="http://newplace.to.link.phone.numbers.to/">' + phoneNumber + '</a>';
*
* case 'twitter' :

@@ -79,2 +88,8 @@ * var twitterHandle = match.getTwitterHandle();

* return '<a href="http://newplace.to.link.twitter.handles.to/">' + twitterHandle + '</a>';
*
* case 'hashtag' :
* var hashtag = match.getHashtag();
* console.log( hashtag );
*
* return '<a href="http://newplace.to.link.hashtag.handles.to/">' + hashtag + '</a>';
* }

@@ -98,2 +113,8 @@ * }

Autolinker.Util.assign( this, cfg ); // assign the properties of `cfg` onto the Autolinker instance. Prototype properties will be used for missing configs.
// Validate the value of the `hashtag` cfg.
var hashtag = this.hashtag;
if( hashtag !== false && hashtag !== 'twitter' && hashtag !== 'facebook' ) {
throw new Error( "invalid `hashtag` cfg - see docs" );
}
};

@@ -133,2 +154,15 @@

/**
* @cfg {Boolean/String} hashtag
*
* A string for the service name to have hashtags (ex: "#myHashtag")
* auto-linked to. The currently-supported values are:
*
* - 'twitter'
* - 'facebook'
*
* Pass `false` to skip auto-linking of hashtags.
*/
hashtag : false,
/**
* @cfg {Boolean} newWindow

@@ -143,4 +177,4 @@ *

*
* `true` if 'http://' or 'https://' and/or the 'www.' should be stripped from the beginning of URL links' text,
* `false` otherwise.
* `true` if 'http://' or 'https://' and/or the 'www.' should be stripped
* from the beginning of URL links' text, `false` otherwise.
*/

@@ -152,4 +186,4 @@ stripPrefix : true,

*
* A number for how many characters long URLs/emails/phone#s/twitter handles should be truncated to inside the text of
* a link. If the URL/email/phone#/twitter is over this number of characters, it will be truncated to this length by
* A number for how many characters long matched text should be truncated to inside the text of
* a link. If the matched text is over this number of characters, it will be truncated to this length by
* adding a two period ellipsis ('..') to the end of the string.

@@ -166,3 +200,3 @@ *

* A CSS class name to add to the generated links. This class will be added to all links, as well as this class
* plus url/email/twitter suffixes for styling url/email/twitter links differently.
* plus match suffixes for styling url/email/phone/twitter/hashtag links differently.
*

@@ -175,2 +209,3 @@ * For example, if this config is provided as "myLink", then:

* - Phone links will have the CSS classes: "myLink myLink-phone"
* - Hashtag links will have the CSS classes: "myLink myLink-hashtag"
*/

@@ -182,3 +217,3 @@ className : "",

*
* A function to individually process each URL/Email/Twitter/Phone match found in the input string.
* A function to individually process each match found in the input string.
*

@@ -192,4 +227,3 @@ * See the class's description for usage.

* @cfg {Autolinker.match.Match} replaceFn.match The Match instance which can be used to retrieve information about the
* {@link Autolinker.match.Url URL}/{@link Autolinker.match.Email email}/{@link Autolinker.match.Phone phone}/{@link Autolinker.match.Twitter Twitter}
* match that the `replaceFn` is currently processing.
* match that the `replaceFn` is currently processing. See {@link Autolinker.match.Match} subclasses for details.
*/

@@ -211,3 +245,3 @@

*
* The MatchParser instance used to find URL/email/Twitter matches in the text nodes of an input string passed to
* The MatchParser instance used to find matches in the text nodes of an input string passed to
* {@link #link}. This is lazily instantiated in the {@link #getMatchParser} method.

@@ -221,3 +255,3 @@ */

*
* The AnchorTagBuilder instance used to build the URL/email/phone/Twitter replacement anchor tags. This is lazily instantiated
* The AnchorTagBuilder instance used to build match replacement anchor tags. Note: this is lazily instantiated
* in the {@link #getTagBuilder} method.

@@ -228,14 +262,19 @@ */

/**
* Automatically links URLs, email addresses, phone numbers, and Twitter handles found in the given chunk of HTML.
* Does not link URLs found within HTML tags.
* Automatically links URLs, Email addresses, Phone numbers, Twitter
* handles, and Hashtags found in the given chunk of HTML. Does not link
* URLs found within HTML tags.
*
* For instance, if given the text: `You should go to http://www.yahoo.com`, then the result
* will be `You should go to &lt;a href="http://www.yahoo.com"&gt;http://www.yahoo.com&lt;/a&gt;`
* For instance, if given the text: `You should go to http://www.yahoo.com`,
* then the result will be `You should go to
* &lt;a href="http://www.yahoo.com"&gt;http://www.yahoo.com&lt;/a&gt;`
*
* This method finds the text around any HTML elements in the input `textOrHtml`, which will be the text that is processed.
* Any original HTML elements will be left as-is, as well as the text that is already wrapped in anchor (&lt;a&gt;) tags.
* This method finds the text around any HTML elements in the input
* `textOrHtml`, which will be the text that is processed. Any original HTML
* elements will be left as-is, as well as the text that is already wrapped
* in anchor (&lt;a&gt;) tags.
*
* @param {String} textOrHtml The HTML or text to link URLs, email addresses, phone numbers, and Twitter handles within (depending on if
* the {@link #urls}, {@link #email}, {@link #phone}, and {@link #twitter} options are enabled).
* @return {String} The HTML, with URLs/emails/phone#s/Twitter handles automatically linked.
* @param {String} textOrHtml The HTML or text to autolink matches within
* (depending on if the {@link #urls}, {@link #email}, {@link #phone},
* {@link #twitter}, and {@link #hashtags} options are enabled).
* @return {String} The HTML, with matches automatically linked.
*/

@@ -286,6 +325,6 @@ link : function( textOrHtml ) {

/**
* Process the text that lies in between HTML tags, performing the anchor tag replacements for matched
* URLs/emails/phone#s/Twitter handles, and returns the string with the replacements made.
* Process the text that lies in between HTML tags, performing the anchor tag replacements for
* the matches, and returns the string with the replacements made.
*
* This method does the actual wrapping of URLs/emails/phone#s/Twitter handles with anchor tags.
* This method does the actual wrapping of matches with anchor tags.
*

@@ -297,3 +336,3 @@ * @private

linkifyStr : function( str ) {
return this.getMatchParser().replace( str, this.createMatchReturnVal, this );
return this.getMatchParser().replace( str, this.createMatchReturnVal, this );
},

@@ -366,6 +405,7 @@

matchParser = this.matchParser = new Autolinker.matchParser.MatchParser( {
urls : this.urls,
email : this.email,
twitter : this.twitter,
phone: this.phone,
urls : this.urls,
email : this.email,
twitter : this.twitter,
phone : this.phone,
hashtag : this.hashtag,
stripPrefix : this.stripPrefix

@@ -418,4 +458,5 @@ } );

/**
* Automatically links URLs, email addresses, and Twitter handles found in the given chunk of HTML.
* Does not link URLs found within HTML tags.
* Automatically links URLs, Email addresses, Phone Numbers, Twitter handles,
* and Hashtags found in the given chunk of HTML. Does not link URLs found
* within HTML tags.
*

@@ -431,7 +472,7 @@ * For instance, if given the text: `You should go to http://www.yahoo.com`, then the result

* @static
* @param {String} textOrHtml The HTML or text to find URLs, email addresses, phone #s, and Twitter handles within (depending on if
* the {@link #urls}, {@link #email}, and {@link #twitter} options are enabled).
* @param {String} textOrHtml The HTML or text to find matches within (depending on if
* the {@link #urls}, {@link #email}, {@link #phone}, {@link #twitter}, and {@link #hashtags} options are enabled).
* @param {Object} [options] Any of the configuration options for the Autolinker class, specified in an Object (map).
* See the class description for an example call.
* @return {String} The HTML text, with URLs automatically linked
* @return {String} The HTML text, with matches automatically linked.
*/

@@ -447,2 +488,2 @@ Autolinker.link = function( textOrHtml, options ) {

Autolinker.htmlParser = {};
Autolinker.matchParser = {};
Autolinker.matchParser = {};

@@ -7,9 +7,8 @@ /*global Autolinker */

*
* Used by Autolinker to parse {@link #urls URLs}, {@link #emails email addresses},
* and {@link #twitter Twitter handles}, given an input string of text.
* Used by Autolinker to parse potential matches, given an input string of text.
*
* The MatchParser is fed a non-HTML string in order to search out URLs, email
* addresses and Twitter handles. Autolinker first uses the {@link HtmlParser}
* to "walk around" HTML tags, and then the text around the HTML tags is passed
* into the MatchParser in order to find the actual matches.
* The MatchParser is fed a non-HTML string in order to search for matches.
* Autolinker first uses the {@link HtmlParser} to "walk around" HTML tags,
* and then the text around the HTML tags is passed into the MatchParser in
* order to find the actual matches.
*/

@@ -20,5 +19,3 @@ Autolinker.matchParser.MatchParser = Autolinker.Util.extend( Object, {

* @cfg {Boolean} urls
*
* `true` if miscellaneous URLs should be automatically linked, `false` if
* they should not.
* @inheritdoc Autolinker#urls
*/

@@ -29,5 +26,3 @@ urls : true,

* @cfg {Boolean} email
*
* `true` if email addresses should be automatically linked, `false` if they
* should not.
* @inheritdoc Autolinker#email
*/

@@ -38,5 +33,3 @@ email : true,

* @cfg {Boolean} twitter
*
* `true` if Twitter handles ("@example") should be automatically linked,
* `false` if they should not.
* @inheritdoc Autolinker#twitter
*/

@@ -47,5 +40,3 @@ twitter : true,

* @cfg {Boolean} phone
*
* `true` if Phone numbers ("(555)555-5555") should be automatically linked,
* `false` if they should not.
* @inheritdoc Autolinker#phone
*/

@@ -55,9 +46,10 @@ phone: true,

/**
* @cfg {Boolean/String} hashtag
* @inheritdoc Autolinker#hashtag
*/
hashtag : false,
/**
* @cfg {Boolean} stripPrefix
*
* `true` if 'http://' or 'https://' and/or the 'www.' should be stripped
* from the beginning of URL links' text in {@link Autolinker.match.Url URL matches},
* `false` otherwise.
*
* TODO: Handle this before a URL Match object is instantiated.
* @inheritdoc Autolinker#stripPrefix
*/

@@ -71,4 +63,4 @@ stripPrefix : true,

*
* The regular expression that matches URLs, email addresses, phone #s, and
* Twitter handles.
* The regular expression that matches URLs, email addresses, phone #s,
* Twitter handles, and Hashtags.
*

@@ -106,11 +98,23 @@ * This regular expression has the following capturing groups:

* next 3 groups give segments of the phone number.
* 10. Group that is used to determine if there is a Hashtag match
* (i.e. \#someHashtag). Simply check for its existence to determine if
* there is a Hashtag match. The next couple of capturing groups give
* information about the Hashtag match.
* 11. The whitespace character before the #sign in a Hashtag handle. This
* is needed because there are no look-behinds in JS regular
* expressions, and can be used to reconstruct the original string in a
* replace().
* 12. The Hashtag itself in a Hashtag match. If the match is
* '#someHashtag', the hashtag is 'someHashtag'.
*/
matcherRegex : (function() {
var twitterRegex = /(^|[^\w])@(\w{1,15})/, // For matching a twitter handle. Ex: @gregory_jacobs
var twitterRegex = /(^|[^\w])@(\w{1,15})/, // For matching a twitter handle. Ex: @gregory_jacobs
emailRegex = /(?:[\-;:&=\+\$,\w\.]+@)/, // something@ for email addresses (a.k.a. local-part)
hashtagRegex = /(^|[^\w])#(\w{1,15})/, // For matching a Hashtag. Ex: #games
emailRegex = /(?:[\-;:&=\+\$,\w\.]+@)/, // something@ for email addresses (a.k.a. local-part)
phoneRegex = /(?:\+?\d{1,3}[-\s.])?\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/, // ex: (123) 456-7890, 123 456 7890, 123-456-7890, etc.
protocolRegex = /(?:[A-Za-z][-.+A-Za-z0-9]+:(?![A-Za-z][-.+A-Za-z0-9]+:\/\/)(?!\d+\/?)(?:\/\/)?)/, // match protocol, allow in format "http://" or "mailto:". However, do not match the first part of something like 'link:http://www.google.com' (i.e. don't match "link:"). Also, make sure we don't interpret 'google.com:8000' as if 'google.com' was a protocol here (i.e. ignore a trailing port number in this regex)
wwwRegex = /(?:www\.)/, // starting with 'www.'
domainNameRegex = /[A-Za-z0-9\.\-]*[A-Za-z0-9\-]/, // anything looking at all like a domain, non-unicode domains, not ending in a period
wwwRegex = /(?:www\.)/, // starting with 'www.'
domainNameRegex = /[A-Za-z0-9\.\-]*[A-Za-z0-9\-]/, // anything looking at all like a domain, non-unicode domains, not ending in a period
tldRegex = /\.(?: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|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/, // match our known top level domains (TLDs)

@@ -172,2 +176,10 @@

phoneRegex.source,
')',
'|',
'(', // *** Capturing group $10, which can be used to check for a Hashtag match. Use group $12 for the actual Hashtag though. $11 may be used to reconstruct the original string in a replace()
// *** Capturing group $11, which matches the whitespace character before the '#' sign (needed because of no lookbehinds), and
// *** Capturing group $12, which matches the actual Hashtag
hashtagRegex.source,
')'

@@ -210,5 +222,4 @@ ].join( "" ), 'gi' );

/**
* Parses the input `text` to search for URLs/emails/Twitter handles, and
* calls the `replaceFn` to allow replacements of the matches. Returns the
* `text` with matches replaced.
* Parses the input `text` to search for matches, and calls the `replaceFn`
* to allow replacements of the matches. Returns the `text` with matches replaced.
*

@@ -226,7 +237,7 @@ * @param {String} text The text to search and repace matches in.

return text.replace( this.matcherRegex, function( matchStr, $1, $2, $3, $4, $5, $6, $7, $8, $9 ) {
var matchDescObj = me.processCandidateMatch( matchStr, $1, $2, $3, $4, $5, $6, $7, $8, $9 ); // "match description" object
return text.replace( this.matcherRegex, function( matchStr, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12 ) {
var matchDescObj = me.processCandidateMatch( matchStr, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12 ); // "match description" object
// Return out with no changes for match types that are disabled (url,
// email, phone, twitter), or for matches that are invalid (false
// email, phone, etc.), or for matches that are invalid (false
// positives from the matcherRegex, which can't use look-behinds

@@ -249,30 +260,53 @@ // since they are unavailable in JS).

*
* Not all matches found by the regex are actual URL/email/Twitter matches, as determined by the {@link #matchValidator}. In
* this case, the method returns `null`. Otherwise, a valid Object with `prefixStr`, `match`, and `suffixStr` is returned.
* Not all matches found by the regex are actual URL/Email/Phone/Twitter/Hashtag
* matches, as determined by the {@link #matchValidator}. In this case, the
* method returns `null`. Otherwise, a valid Object with `prefixStr`,
* `match`, and `suffixStr` is returned.
*
* @private
* @param {String} matchStr The full match that was found by the {@link #matcherRegex}.
* @param {String} twitterMatch The matched text of a Twitter handle, if the match is a Twitter match.
* @param {String} twitterHandlePrefixWhitespaceChar The whitespace char before the @ sign in a Twitter handle match. This
* is needed because of no lookbehinds in JS regexes, and is need to re-include the character for the anchor tag replacement.
* @param {String} twitterHandle The actual Twitter user (i.e the word after the @ sign in a Twitter match).
* @param {String} emailAddressMatch The matched email address for an email address match.
* @param {String} matchStr The full match that was found by the
* {@link #matcherRegex}.
* @param {String} twitterMatch The matched text of a Twitter handle, if the
* match is a Twitter match.
* @param {String} twitterHandlePrefixWhitespaceChar The whitespace char
* before the @ sign in a Twitter handle match. This is needed because of
* no lookbehinds in JS regexes, and is need to re-include the character
* for the anchor tag replacement.
* @param {String} twitterHandle The actual Twitter user (i.e the word after
* the @ sign in a Twitter match).
* @param {String} emailAddressMatch The matched email address for an email
* address match.
* @param {String} urlMatch The matched URL string for a URL match.
* @param {String} protocolUrlMatch The match URL string for a protocol match. Ex: 'http://yahoo.com'. This is used to match
* something like 'http://localhost', where we won't double check that the domain name has at least one '.' in it.
* @param {String} wwwProtocolRelativeMatch The '//' for a protocol-relative match from a 'www' url, with the character that
* @param {String} protocolUrlMatch The match URL string for a protocol
* match. Ex: 'http://yahoo.com'. This is used to match something like
* 'http://localhost', where we won't double check that the domain name
* has at least one '.' in it.
* @param {String} wwwProtocolRelativeMatch The '//' for a protocol-relative
* match from a 'www' url, with the character that comes before the '//'.
* @param {String} tldProtocolRelativeMatch The '//' for a protocol-relative
* match from a TLD (top level domain) match, with the character that
* comes before the '//'.
* @param {String} tldProtocolRelativeMatch The '//' for a protocol-relative match from a TLD (top level domain) match, with
* the character that comes before the '//'.
* @param {String} phoneMatch The matched text of a phone number
* @param {String} hashtagMatch The matched text of a Twitter
* Hashtag, if the match is a Hashtag match.
* @param {String} hashtagPrefixWhitespaceChar The whitespace char
* before the # sign in a Hashtag match. This is needed because of no
* lookbehinds in JS regexes, and is need to re-include the character for
* the anchor tag replacement.
* @param {String} hashtag The actual Hashtag (i.e the word
* after the # sign in a Hashtag match).
*
* @return {Object} A "match description object". This will be `null` if the match was invalid, or if a match type is disabled.
* Otherwise, this will be an Object (map) with the following properties:
* @return {String} return.prefixStr The char(s) that should be prepended to the replacement string. These are char(s) that
* were needed to be included from the regex match that were ignored by processing code, and should be re-inserted into
* the replacement stream.
* @return {String} return.suffixStr The char(s) that should be appended to the replacement string. These are char(s) that
* were needed to be included from the regex match that were ignored by processing code, and should be re-inserted into
* the replacement stream.
* @return {Autolinker.match.Match} return.match The Match object that represents the match that was found.
* @return {Object} A "match description object". This will be `null` if the
* match was invalid, or if a match type is disabled. Otherwise, this will
* be an Object (map) with the following properties:
* @return {String} return.prefixStr The char(s) that should be prepended to
* the replacement string. These are char(s) that were needed to be
* included from the regex match that were ignored by processing code, and
* should be re-inserted into the replacement stream.
* @return {String} return.suffixStr The char(s) that should be appended to
* the replacement string. These are char(s) that were needed to be
* included from the regex match that were ignored by processing code, and
* should be re-inserted into the replacement stream.
* @return {Autolinker.match.Match} return.match The Match object that
* represents the match that was found.
*/

@@ -282,3 +316,5 @@ processCandidateMatch : function(

emailAddressMatch, urlMatch, protocolUrlMatch, wwwProtocolRelativeMatch,
tldProtocolRelativeMatch, phoneMatch ) {
tldProtocolRelativeMatch, phoneMatch, hashtagMatch,
hashtagPrefixWhitespaceChar, hashtag
) {
// Note: The `matchStr` variable wil be fixed up to remove characters that are no longer needed (which will

@@ -290,9 +326,13 @@ // be added to `prefixStr` and `suffixStr`).

prefixStr = "", // A string to use to prefix the anchor tag that is created. This is needed for the Twitter handle match
suffixStr = ""; // A string to suffix the anchor tag that is created. This is used if there is a trailing parenthesis that should not be auto-linked.
prefixStr = "", // A string to use to prefix the anchor tag that is created. This is needed for the Twitter and Hashtag matches.
suffixStr = ""; // A string to suffix the anchor tag that is created. This is used if there is a trailing parenthesis that should not be auto-linked.
// Return out with `null` for match types that are disabled (url, email, twitter), or for matches that are
// Return out with `null` for match types that are disabled (url, email, twitter, hashtag), or for matches that are
// invalid (false positives from the matcherRegex, which can't use look-behinds since they are unavailable in JS).
if(
( twitterMatch && !this.twitter ) || ( emailAddressMatch && !this.email ) || ( urlMatch && !this.urls ) || (phoneMatch && !this.phone) ||
( urlMatch && !this.urls ) ||
( emailAddressMatch && !this.email ) ||
( phoneMatch && !this.phone ) ||
( twitterMatch && !this.twitter ) ||
( hashtagMatch && !this.hashtag ) ||
!this.matchValidator.isValidMatch( urlMatch, protocolUrlMatch, protocolRelativeMatch )

@@ -322,3 +362,3 @@ ) {

} else if ( phoneMatch ) {
} else if( phoneMatch ) {
// remove non-numeric values from phone number string

@@ -328,2 +368,11 @@ var cleanNumber = matchStr.replace( /\D/g, '' );

} else if( hashtagMatch ) {
// fix up the `matchStr` if there was a preceding whitespace char, which was needed to determine the match
// itself (since there are no look-behinds in JS regexes)
if( hashtagPrefixWhitespaceChar ) {
prefixStr = hashtagPrefixWhitespaceChar;
matchStr = matchStr.slice( 1 ); // remove the prefixed whitespace char from the match
}
match = new Autolinker.match.Hashtag( { matchedText: matchStr, serviceName: this.hashtag, hashtag: hashtag } );
} else { // url match

@@ -342,7 +391,7 @@ // If it's a protocol-relative '//' match, remove the character before the '//' (which the matcherRegex needed

match = new Autolinker.match.Url( {
matchedText : matchStr,
url : matchStr,
protocolUrlMatch : !!protocolUrlMatch,
matchedText : matchStr,
url : matchStr,
protocolUrlMatch : !!protocolUrlMatch,
protocolRelativeMatch : !!protocolRelativeMatch,
stripPrefix : this.stripPrefix
stripPrefix : this.stripPrefix
} );

@@ -391,2 +440,2 @@ }

} );
} );

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

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

Sorry, the diff of this file is not supported yet

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