Skip to content

Commit 03bb04c

Browse files
committed
Build 1.7.1
1 parent 7d50d14 commit 03bb04c

File tree

4 files changed

+75
-61
lines changed

4 files changed

+75
-61
lines changed

dist/Autolinker.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Autolinker.js
3-
* 1.6.2
3+
* 1.7.1
44
*
55
* Copyright(c) 2018 Gregory Jacobs <[email protected]>
66
* MIT License
@@ -241,7 +241,7 @@ Autolinker.parse = function( textOrHtml, options ) {
241241
*
242242
* Ex: 0.25.1
243243
*/
244-
Autolinker.version = '1.6.2';
244+
Autolinker.version = '1.7.1';
245245

246246

247247
Autolinker.prototype = {
@@ -685,7 +685,7 @@ Autolinker.prototype = {
685685
}
686686

687687
// Remove subsequent matches that overlap with the current match
688-
if( matches[ i + 1 ].getOffset() <= endIdx ) {
688+
if( matches[ i + 1 ].getOffset() < endIdx ) {
689689
matches.splice( i + 1, 1 );
690690
}
691691
}
@@ -3412,15 +3412,15 @@ Autolinker.matcher.Phone = Autolinker.Util.extend( Autolinker.matcher.Matcher, {
34123412
*
34133413
* This regular expression has the following capturing groups:
34143414
*
3415-
* 1. The prefixed '+' sign, if there is one.
3415+
* 1 or 2. The prefixed '+' sign, if there is one.
34163416
*
34173417
* @private
34183418
* @property {RegExp} matcherRegex
34193419
*/
3420-
matcherRegex : /(?:(\+)?\d{1,3}[-\040.]?)?\(?\d{3}\)?[-\040.]?\d{3}[-\040.]?\d{4}([,;]*[0-9]+#?)*/g,
3421-
3422-
// ex: (123) 456-7890, 123 456 7890, 123-456-7890, +18004441234,,;,10226420346#,
3423-
// +1 (800) 444 1234, 10226420346#, 1-800-444-1234,1022,64,20346#
3420+
matcherRegex : /(?:(?:(?:(\+)?\d{1,3}[-\040.]?)?\(?\d{3}\)?[-\040.]?\d{3}[-\040.]?\d{4})|(?:(\+)(?:9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)[-\040.]?(?:\d[-\040.]?){6,12}\d+))([,;]+[0-9]+#?)*/g,
3421+
3422+
// ex: (123) 456-7890, 123 456 7890, 123-456-7890, +18004441234,,;,10226420346#,
3423+
// +1 (800) 444 1234, 10226420346#, 1-800-444-1234,1022,64,20346#
34243424

34253425
/**
34263426
* @inheritdoc
@@ -3435,16 +3435,20 @@ Autolinker.matcher.Phone = Autolinker.Util.extend( Autolinker.matcher.Matcher, {
34353435
// Remove non-numeric values from phone number string
34363436
var matchedText = match[0],
34373437
cleanNumber = matchedText.replace(/[^0-9,;#]/g, ''), // strip out non-digit characters exclude comma semicolon and #
3438-
plusSign = !!match[1]; // match[ 1 ] is the prefixed plus sign, if there is one
3439-
if (this.testMatch(match[2]) && this.testMatch(matchedText)) {
3440-
matches.push(new Autolinker.match.Phone({
3441-
tagBuilder: tagBuilder,
3442-
matchedText: matchedText,
3443-
offset: match.index,
3444-
number: cleanNumber,
3445-
plusSign: plusSign
3446-
}));
3447-
}
3438+
plusSign = !!(match[1] || match[2]), // match[ 1 ] or match[ 2 ] is the prefixed plus sign, if there is one
3439+
before = match.index == 0 ? '' : text.substr(match.index - 1, 1),
3440+
after = text.substr(match.index + matchedText.length, 1),
3441+
contextClear = !before.match(/\d/) && !after.match(/\d/);
3442+
3443+
if (this.testMatch(match[3]) && this.testMatch(matchedText) && contextClear) {
3444+
matches.push(new Autolinker.match.Phone({
3445+
tagBuilder: tagBuilder,
3446+
matchedText: matchedText,
3447+
offset: match.index,
3448+
number: cleanNumber,
3449+
plusSign: plusSign
3450+
}));
3451+
}
34483452
}
34493453

34503454
return matches;

dist/Autolinker.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dist/Autolinker.js

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Autolinker.js
3-
* 1.6.1
3+
* 1.7.1
44
*
55
* Copyright(c) 2018 Gregory Jacobs <[email protected]>
66
* MIT License
@@ -241,7 +241,7 @@ Autolinker.parse = function( textOrHtml, options ) {
241241
*
242242
* Ex: 0.25.1
243243
*/
244-
Autolinker.version = '1.6.1';
244+
Autolinker.version = '1.7.1';
245245

246246

247247
Autolinker.prototype = {
@@ -685,7 +685,7 @@ Autolinker.prototype = {
685685
}
686686

687687
// Remove subsequent matches that overlap with the current match
688-
if( matches[ i + 1 ].getOffset() <= endIdx ) {
688+
if( matches[ i + 1 ].getOffset() < endIdx ) {
689689
matches.splice( i + 1, 1 );
690690
}
691691
}
@@ -1558,13 +1558,19 @@ Autolinker.RegexLib = (function() {
15581558
var alphaNumericCharsStr = alphaCharsStr + decimalNumbersStr;
15591559

15601560
// Simplified IP regular expression
1561-
var ipRegex = new RegExp( '(?:[' + decimalNumbersStr + ']{1,3}\\.){3}[' + decimalNumbersStr + ']{1,3}' );
1561+
var ipStr = '(?:[' + decimalNumbersStr + ']{1,3}\\.){3}[' + decimalNumbersStr + ']{1,3}';
15621562

15631563
// Protected domain label which do not allow "-" character on the beginning and the end of a single label
1564-
var domainLabelStr = '[' + alphaNumericCharsStr + '](?:[' + alphaNumericCharsStr + '\\-]*[' + alphaNumericCharsStr + '])?';
1564+
var domainLabelStr = '[' + alphaNumericCharsStr + '](?:[' + alphaNumericCharsStr + '\\-]{0,61}[' + alphaNumericCharsStr + '])?';
1565+
1566+
var getDomainLabelStr = function(group) {
1567+
return '(?=(' + domainLabelStr + '))\\' + group;
1568+
};
15651569

15661570
// See documentation below
1567-
var domainNameRegex = new RegExp( '(?:(?:(?:' + domainLabelStr + '\\.)*(?:' + domainLabelStr + '))|(?:' + ipRegex.source + '))' );
1571+
var getDomainNameStr = function(group) {
1572+
return '(?:' + getDomainLabelStr(group) + '(?:\\.' + getDomainLabelStr(group + 1) + '){0,126}|' + ipStr + ')';
1573+
};
15681574

15691575
return {
15701576

@@ -1598,7 +1604,7 @@ Autolinker.RegexLib = (function() {
15981604
*
15991605
* @property {RegExp} domainNameRegex
16001606
*/
1601-
domainNameRegex : domainNameRegex,
1607+
getDomainNameStr : getDomainNameStr,
16021608

16031609
};
16041610

@@ -3264,12 +3270,12 @@ Autolinker.matcher.Email = Autolinker.Util.extend( Autolinker.matcher.Matcher, {
32643270
validCharacters = alphaNumericChars + specialCharacters,
32653271
validRestrictedCharacters = validCharacters + restrictedSpecialCharacters,
32663272
emailRegex = new RegExp( '(?:[' + validCharacters + '](?:[' + validCharacters + ']|\\.(?!\\.|@))*|\\"[' + validRestrictedCharacters + '.]+\\")@'),
3267-
domainNameRegex = Autolinker.RegexLib.domainNameRegex,
3273+
getDomainNameStr = Autolinker.RegexLib.getDomainNameStr,
32683274
tldRegex = Autolinker.tldRegex; // match our known top level domains (TLDs)
32693275

32703276
return new RegExp( [
32713277
emailRegex.source,
3272-
domainNameRegex.source,
3278+
getDomainNameStr(1),
32733279
'\\.', tldRegex.source // '.com', '.net', etc
32743280
].join( "" ), 'gi' );
32753281
} )(),
@@ -3406,15 +3412,15 @@ Autolinker.matcher.Phone = Autolinker.Util.extend( Autolinker.matcher.Matcher, {
34063412
*
34073413
* This regular expression has the following capturing groups:
34083414
*
3409-
* 1. The prefixed '+' sign, if there is one.
3415+
* 1 or 2. The prefixed '+' sign, if there is one.
34103416
*
34113417
* @private
34123418
* @property {RegExp} matcherRegex
34133419
*/
3414-
matcherRegex : /(?:(\+)?\d{1,3}[-\040.]?)?\(?\d{3}\)?[-\040.]?\d{3}[-\040.]?\d{4}([,;]*[0-9]+#?)*/g,
3415-
3416-
// ex: (123) 456-7890, 123 456 7890, 123-456-7890, +18004441234,,;,10226420346#,
3417-
// +1 (800) 444 1234, 10226420346#, 1-800-444-1234,1022,64,20346#
3420+
matcherRegex : /(?:(?:(?:(\+)?\d{1,3}[-\040.]?)?\(?\d{3}\)?[-\040.]?\d{3}[-\040.]?\d{4})|(?:(\+)(?:9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)[-\040.]?(?:\d[-\040.]?){6,12}\d+))([,;]+[0-9]+#?)*/g,
3421+
3422+
// ex: (123) 456-7890, 123 456 7890, 123-456-7890, +18004441234,,;,10226420346#,
3423+
// +1 (800) 444 1234, 10226420346#, 1-800-444-1234,1022,64,20346#
34183424

34193425
/**
34203426
* @inheritdoc
@@ -3429,16 +3435,20 @@ Autolinker.matcher.Phone = Autolinker.Util.extend( Autolinker.matcher.Matcher, {
34293435
// Remove non-numeric values from phone number string
34303436
var matchedText = match[0],
34313437
cleanNumber = matchedText.replace(/[^0-9,;#]/g, ''), // strip out non-digit characters exclude comma semicolon and #
3432-
plusSign = !!match[1]; // match[ 1 ] is the prefixed plus sign, if there is one
3433-
if (this.testMatch(match[2]) && this.testMatch(matchedText)) {
3434-
matches.push(new Autolinker.match.Phone({
3435-
tagBuilder: tagBuilder,
3436-
matchedText: matchedText,
3437-
offset: match.index,
3438-
number: cleanNumber,
3439-
plusSign: plusSign
3440-
}));
3441-
}
3438+
plusSign = !!(match[1] || match[2]), // match[ 1 ] or match[ 2 ] is the prefixed plus sign, if there is one
3439+
before = match.index == 0 ? '' : text.substr(match.index - 1, 1),
3440+
after = text.substr(match.index + matchedText.length, 1),
3441+
contextClear = !before.match(/\d/) && !after.match(/\d/);
3442+
3443+
if (this.testMatch(match[3]) && this.testMatch(matchedText) && contextClear) {
3444+
matches.push(new Autolinker.match.Phone({
3445+
tagBuilder: tagBuilder,
3446+
matchedText: matchedText,
3447+
offset: match.index,
3448+
number: cleanNumber,
3449+
plusSign: plusSign
3450+
}));
3451+
}
34423452
}
34433453

34443454
return matches;
@@ -3600,9 +3610,9 @@ Autolinker.matcher.Url = Autolinker.Util.extend( Autolinker.matcher.Matcher, {
36003610
* See #3 for more info.
36013611
*/
36023612
matcherRegex : (function() {
3603-
var schemeRegex = /(?:[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)
3613+
var schemeRegex = /(?:[A-Za-z][-.+A-Za-z0-9]{0,63}:(?![A-Za-z][-.+A-Za-z0-9]{0,63}:\/\/)(?!\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)
36043614
wwwRegex = /(?:www\.)/, // starting with 'www.'
3605-
domainNameRegex = Autolinker.RegexLib.domainNameRegex,
3615+
getDomainNameStr = Autolinker.RegexLib.getDomainNameStr,
36063616
tldRegex = Autolinker.tldRegex, // match our known top level domains (TLDs)
36073617
alphaNumericCharsStr = Autolinker.RegexLib.alphaNumericCharsStr,
36083618

@@ -3614,22 +3624,22 @@ Autolinker.matcher.Url = Autolinker.Util.extend( Autolinker.matcher.Matcher, {
36143624
'(?:', // parens to cover match for scheme (optional), and domain
36153625
'(', // *** Capturing group $1, for a scheme-prefixed url (ex: http://google.com)
36163626
schemeRegex.source,
3617-
domainNameRegex.source,
3627+
getDomainNameStr(2),
36183628
')',
36193629

36203630
'|',
36213631

3622-
'(', // *** Capturing group $2, for a 'www.' prefixed url (ex: www.google.com)
3623-
'(//)?', // *** Capturing group $3 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character (handled later)
3632+
'(', // *** Capturing group $4 for a 'www.' prefixed url (ex: www.google.com)
3633+
'(//)?', // *** Capturing group $5 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character (handled later)
36243634
wwwRegex.source,
3625-
domainNameRegex.source,
3635+
getDomainNameStr(6),
36263636
')',
36273637

36283638
'|',
36293639

3630-
'(', // *** Capturing group $4, for known a TLD url (ex: google.com)
3631-
'(//)?', // *** Capturing group $5 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character (handled later)
3632-
domainNameRegex.source + '\\.',
3640+
'(', // *** Capturing group $8, for known a TLD url (ex: google.com)
3641+
'(//)?', // *** Capturing group $9 for an optional protocol-relative URL. Must be at the beginning of the string or start with a non-word character (handled later)
3642+
getDomainNameStr(10) + '\\.',
36333643
tldRegex.source,
36343644
'(?![-' + alphaNumericCharsStr + '])', // TLD not followed by a letter, behaves like unicode-aware \b
36353645
')',
@@ -3716,10 +3726,10 @@ Autolinker.matcher.Url = Autolinker.Util.extend( Autolinker.matcher.Matcher, {
37163726
while( ( match = matcherRegex.exec( text ) ) !== null ) {
37173727
var matchStr = match[ 0 ],
37183728
schemeUrlMatch = match[ 1 ],
3719-
wwwUrlMatch = match[ 2 ],
3720-
wwwProtocolRelativeMatch = match[ 3 ],
3721-
//tldUrlMatch = match[ 4 ], -- not needed at the moment
3722-
tldProtocolRelativeMatch = match[ 5 ],
3729+
wwwUrlMatch = match[ 4 ],
3730+
wwwProtocolRelativeMatch = match[ 5 ],
3731+
//tldUrlMatch = match[ 8 ], -- not needed at the moment
3732+
tldProtocolRelativeMatch = match[ 9 ],
37233733
offset = match.index,
37243734
protocolRelativeMatch = wwwProtocolRelativeMatch || tldProtocolRelativeMatch,
37253735
prevChar = text.charAt( offset - 1 );

docs/dist/Autolinker.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)