Skip to content

Commit e48391d

Browse files
committed
Build v3.0.2
1 parent acd8179 commit e48391d

15 files changed

+172
-133
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"editor.insertSpaces": false,
3-
"editor.rulers": [ 80 ]
3+
"editor.rulers": [
4+
80
5+
],
6+
"search.usePCRE2": true
47
}

dist/Autolinker.js

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

dist/Autolinker.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Autolinker.min.js

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

dist/Autolinker.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/data-b8cedd8364139db25df03474c1b41392.js renamed to docs/api/data-1b30d390b465ca8f0654fce2cf9e7182.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>Autolinker v3.0.1 API Docs</title>
4+
<title>Autolinker v3.0.2 API Docs</title>
55
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
66
<meta http-equiv="X-UA-Compatible" content="chrome=1">
77
<meta name="fragment" content="!">
@@ -13,7 +13,7 @@
1313
<link rel="stylesheet" href="styles-3eba09980fa05ead185cb17d9c0deb0f.css" type="text/css" />
1414

1515
<script type="text/javascript" src="extjs/ext-all.js"></script>
16-
<script type="text/javascript" src="data-b8cedd8364139db25df03474c1b41392.js"></script>
16+
<script type="text/javascript" src="data-1b30d390b465ca8f0654fce2cf9e7182.js"></script>
1717

1818
<script type="text/javascript" src="app-0c945a27f43452df695771ddb60b3d14.js"></script>
1919

@@ -22,9 +22,9 @@
2222
</head>
2323
<body id="ext-body">
2424

25-
<div id="loading"><span class="title">Autolinker v3.0.1 API Docs</span><span class="logo"></span></div>
25+
<div id="loading"><span class="title">Autolinker v3.0.2 API Docs</span><span class="logo"></span></div>
2626

27-
<div id="header-content">Autolinker v3.0.1 API Docs</div>
27+
<div id="header-content">Autolinker v3.0.2 API Docs</div>
2828

2929
<div id='categories-content' style='display:none'>
3030
<div class='section'>
@@ -88,7 +88,7 @@ <h3>Others...</h3>
8888

8989

9090

91-
<div id='footer-content' style='display: none'>Generated on Mon 18 Feb 2019 17:12:14 by <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> 5.3.4.</div>
91+
<div id='footer-content' style='display: none'>Generated on Wed 20 Feb 2019 17:07:14 by <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> 5.3.4.</div>
9292

9393

9494

docs/api/output/Autolinker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/output/Autolinker.matcher.Url.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/output/global.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/source/Autolinker.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@
859859
*
860860
* Ex: 0.25.1
861861
*/
862-
Autolinker.version = &#39;3.0.1&#39;;
862+
Autolinker.version = &#39;3.0.2&#39;;
863863
<span id='Autolinker-AnchorTagBuilder'> /**
864864
</span> * For backwards compatibility with Autolinker 1.x, the AnchorTagBuilder
865865
* class is provided as a static on the Autolinker class.

docs/api/source/url-matcher.html

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -134,29 +134,6 @@
134134
* @type {RegExp} wordCharRegExp
135135
*/
136136
_this.wordCharRegExp = new RegExp(&#39;[&#39; + regex_lib_1.alphaNumericAndMarksCharsStr + &#39;]&#39;);
137-
<span id='Autolinker-matcher-Url-property-openParensRe'> /**
138-
</span> * The regular expression to match opening parenthesis in a URL match.
139-
*
140-
* This is to determine if we have unbalanced parenthesis in the URL, and to
141-
* drop the final parenthesis that was matched if so.
142-
*
143-
* Ex: The text &quot;(check out: wikipedia.com/something_(disambiguation))&quot;
144-
* should only autolink the inner &quot;wikipedia.com/something_(disambiguation)&quot;
145-
* part, so if we find that we have unbalanced parenthesis, we will drop the
146-
* last one for the match.
147-
*
148-
* @protected
149-
* @property {RegExp}
150-
*/
151-
_this.openParensRe = /\(/g;
152-
<span id='Autolinker-matcher-Url-property-closeParensRe'> /**
153-
</span> * The regular expression to match closing parenthesis in a URL match. See
154-
* {@link #openParensRe} for more information.
155-
*
156-
* @protected
157-
* @property {RegExp}
158-
*/
159-
_this.closeParensRe = /\)/g;
160137
_this.stripPrefix = cfg.stripPrefix;
161138
_this.stripTrailingSlash = cfg.stripTrailingSlash;
162139
_this.decodePercentEncoding = cfg.decodePercentEncoding;
@@ -186,12 +163,15 @@
186163
if (offset &gt; 0 &amp;&amp; protocolRelativeMatch &amp;&amp; this.wordCharRegExp.test(prevChar)) {
187164
continue;
188165
}
166+
// If the URL ends with a question mark, don&#39;t include the question
167+
// mark as part of the URL. We&#39;ll assume the question mark was the
168+
// end of a sentence, such as: &quot;Going to google.com?&quot;
189169
if (/\?$/.test(matchStr)) {
190170
matchStr = matchStr.substr(0, matchStr.length - 1);
191171
}
192-
// Handle a closing parenthesis at the end of the match, and exclude
193-
// it if there is not a matching open parenthesis in the match
194-
// itself.
172+
// Handle a closing parenthesis or square bracket at the end of the
173+
// match, and exclude it if there is not a matching open parenthesis
174+
// or square bracket in the match itself.
195175
if (this.matchHasUnbalancedClosingParen(matchStr)) {
196176
matchStr = matchStr.substr(0, matchStr.length - 1); // remove the trailing &quot;)&quot;
197177
}
@@ -219,32 +199,64 @@
219199
return matches;
220200
};
221201
<span id='Autolinker-matcher-Url-method-matchHasUnbalancedClosingParen'> /**
222-
</span> * Determines if a match found has an unmatched closing parenthesis. If so,
223-
* this parenthesis will be removed from the match itself, and appended
224-
* after the generated anchor tag.
202+
</span> * Determines if a match found has an unmatched closing parenthesis or
203+
* square bracket. If so, the parenthesis or square bracket will be removed
204+
* from the match itself, and appended after the generated anchor tag.
225205
*
226206
* A match may have an extra closing parenthesis at the end of the match
227207
* because the regular expression must include parenthesis for URLs such as
228208
* &quot;wikipedia.com/something_(disambiguation)&quot;, which should be auto-linked.
229209
*
230210
* However, an extra parenthesis *will* be included when the URL itself is
231-
* wrapped in parenthesis, such as in the case of &quot;(wikipedia.com/something_(disambiguation))&quot;.
211+
* wrapped in parenthesis, such as in the case of:
212+
* &quot;(wikipedia.com/something_(disambiguation))&quot;
232213
* In this case, the last closing parenthesis should *not* be part of the
233214
* URL itself, and this method will return `true`.
234215
*
216+
* For square brackets in URLs such as in PHP arrays, the same behavior as
217+
* parenthesis discussed above should happen:
218+
* &quot;[http://www.example.com/foo.php?bar[]=1&amp;bar[]=2&amp;bar[]=3]&quot;
219+
* The closing square bracket should not be part of the URL itself, and this
220+
* method will return `true`.
221+
*
235222
* @protected
236223
* @param {String} matchStr The full match string from the {@link #matcherRegex}.
237-
* @return {Boolean} `true` if there is an unbalanced closing parenthesis at
238-
* the end of the `matchStr`, `false` otherwise.
224+
* @return {Boolean} `true` if there is an unbalanced closing parenthesis or
225+
* square bracket at the end of the `matchStr`, `false` otherwise.
239226
*/
240227
UrlMatcher.prototype.matchHasUnbalancedClosingParen = function (matchStr) {
241-
var lastChar = matchStr.charAt(matchStr.length - 1);
242-
if (lastChar === &#39;)&#39;) {
243-
var openParensMatch = matchStr.match(this.openParensRe), closeParensMatch = matchStr.match(this.closeParensRe), numOpenParens = (openParensMatch &amp;&amp; openParensMatch.length) || 0, numCloseParens = (closeParensMatch &amp;&amp; closeParensMatch.length) || 0;
244-
if (numOpenParens &lt; numCloseParens) {
245-
return true;
228+
var endChar = matchStr.charAt(matchStr.length - 1);
229+
var startChar;
230+
if (endChar === &#39;)&#39;) {
231+
startChar = &#39;(&#39;;
232+
}
233+
else if (endChar === &#39;]&#39;) {
234+
startChar = &#39;[&#39;;
235+
}
236+
else {
237+
return false; // not a close parenthesis or square bracket
238+
}
239+
// Find if there are the same number of open braces as close braces in
240+
// the URL string, minus the last character (which we have already
241+
// determined to be either &#39;)&#39; or &#39;]&#39;
242+
var numOpenBraces = 0;
243+
for (var i = 0, len = matchStr.length - 1; i &lt; len; i++) {
244+
var char = matchStr.charAt(i);
245+
if (char === startChar) {
246+
numOpenBraces++;
247+
}
248+
else if (char === endChar) {
249+
numOpenBraces = Math.max(numOpenBraces - 1, 0);
246250
}
247251
}
252+
// If the number of open braces matches the number of close braces in
253+
// the URL minus the last character, then the match has *unbalanced*
254+
// braces because of the last character. Example of unbalanced braces
255+
// from the regex match:
256+
// &quot;http://example.com?a[]=1]&quot;
257+
if (numOpenBraces === 0) {
258+
return true;
259+
}
248260
return false;
249261
};
250262
<span id='Autolinker-matcher-Url-method-matchHasInvalidCharAfterTld'> /**

0 commit comments

Comments
 (0)