You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 5. Group that matches a URL in the input text. Ex: 'http://google.com', 'www.google.com', or just 'google.com'.
205
205
* This also includes a path, url parameters, or hash anchors. Ex: google.com/path/to/file?q1=1&q2=2#myAnchor
206
-
* 6. A protocol-relative ('//') match for the case of a 'www.' prefixed URL. Will be an empty string if it is not a
206
+
* 6. Group that matches a protocol URL (i.e. 'http://google.com'). This is used to match protocol URLs with just a single
207
+
* word, like 'http://localhost', where we won't double check that the domain name has at least one '.' in it.
208
+
* 7. A protocol-relative ('//') match for the case of a 'www.' prefixed URL. Will be an empty string if it is not a
207
209
* protocol-relative match. We need to know the character before the '//' in order to determine if it is a valid match
208
210
* or the // was in a string we don't want to auto-link.
209
-
* 7. A protocol-relative ('//') match for the case of a known TLD prefixed URL. Will be an empty string if it is not a
211
+
* 8. A protocol-relative ('//') match for the case of a known TLD prefixed URL. Will be an empty string if it is not a
210
212
* protocol-relative match. See #6 for more info.
211
213
*/
212
214
matcherRegex : (function(){
213
215
vartwitterRegex=/(^|[^\w])@(\w{1,15})/,// For matching a twitter handle. Ex: @gregory_jacobs
214
216
215
217
emailRegex=/(?:[\-;:&=\+\$,\w\.]+@)/,// something@ for email addresses (a.k.a. local-part)
216
218
217
-
protocolRegex=/(?:[A-Za-z]{3,9}:(?![A-Za-z]{3,9}:\/\/)(?:\/\/)?)/,// match protocol, allow in format http:// or mailto:
219
+
protocolRegex=/(?:[A-Za-z]{3,9}:(?![A-Za-z]{3,9}:\/\/)(?:\/\/)?)/,// 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:")
218
220
wwwRegex=/(?:www\.)/,// starting with 'www.'
219
221
domainNameRegex=/[A-Za-z0-9\.\-]*[A-Za-z0-9\-]/,// anything looking at all like a domain, non-unicode domains, not ending in a period
220
222
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)
@@ -242,23 +244,23 @@ Autolinker.prototype = {
242
244
243
245
'(',// *** Capturing group $5, which is used to match a URL
244
246
'(?:',// parens to cover match for protocol (optional), and domain
245
-
'(?:',// non-capturing paren for a protocol-prefixed url (ex: http://google.com)
247
+
'(',// *** Capturing group $6, for a protocol-prefixed url (ex: http://google.com)
246
248
protocolRegex.source,
247
249
domainNameRegex.source,
248
250
')',
249
251
250
252
'|',
251
253
252
254
'(?:',// non-capturing paren for a 'www.' prefixed url (ex: www.google.com)
253
-
'(.?//)?',// *** Capturing group $6 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character
255
+
'(.?//)?',// *** Capturing group $7 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character
254
256
wwwRegex.source,
255
257
domainNameRegex.source,
256
258
')',
257
259
258
260
'|',
259
261
260
262
'(?:',// non-capturing paren for known a TLD url (ex: google.com)
261
-
'(.?//)?',// *** Capturing group $7 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character
263
+
'(.?//)?',// *** Capturing group $8 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character
(urlMatch&&urlMatch.indexOf('.')===-1)||// At least one period ('.') must exist in the URL match for us to consider it an actual URL
588
+
(urlMatch&&(!protocolUrlMatch||!(/:\/\//).test(protocolUrlMatch))&&urlMatch.indexOf('.')===-1)||// At least one period ('.') must exist in the URL match for us to consider it an actual URL, *unless* it was a full protocol match (like 'http://localhost')
583
589
(urlMatch&&/^[A-Za-z]{3,9}:/.test(urlMatch)&&!/:.*?[A-Za-z]/.test(urlMatch))||// At least one letter character must exist in the domain name after a protocol match. Ex: skip over something like "git:1.0"
584
590
(protocolRelativeMatch&&this.invalidProtocolRelMatchRegex.test(protocolRelativeMatch))// a protocol-relative match which has a word character in front of it (so we can skip something like "abc//google.com")
0 commit comments