Skip to content

Commit

Permalink
Build v3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gregjacobs committed Feb 20, 2019
1 parent acd8179 commit e48391d
Show file tree
Hide file tree
Showing 15 changed files with 172 additions and 133 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
@@ -1,4 +1,7 @@
{
"editor.insertSpaces": false,
"editor.rulers": [ 80 ]
"editor.rulers": [
80
],
"search.usePCRE2": true
}
90 changes: 51 additions & 39 deletions dist/Autolinker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/Autolinker.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/Autolinker.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/Autolinker.min.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/api/index.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Autolinker v3.0.1 API Docs</title>
<title>Autolinker v3.0.2 API Docs</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="fragment" content="!">
Expand All @@ -13,7 +13,7 @@
<link rel="stylesheet" href="styles-3eba09980fa05ead185cb17d9c0deb0f.css" type="text/css" />

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

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

Expand All @@ -22,9 +22,9 @@
</head>
<body id="ext-body">

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

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

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



<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>
<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>



Expand Down
2 changes: 1 addition & 1 deletion docs/api/output/Autolinker.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/output/Autolinker.matcher.Url.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/output/global.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/source/Autolinker.html
Expand Up @@ -859,7 +859,7 @@
*
* Ex: 0.25.1
*/
Autolinker.version = &#39;3.0.1&#39;;
Autolinker.version = &#39;3.0.2&#39;;
<span id='Autolinker-AnchorTagBuilder'> /**
</span> * For backwards compatibility with Autolinker 1.x, the AnchorTagBuilder
* class is provided as a static on the Autolinker class.
Expand Down
86 changes: 49 additions & 37 deletions docs/api/source/url-matcher.html
Expand Up @@ -134,29 +134,6 @@
* @type {RegExp} wordCharRegExp
*/
_this.wordCharRegExp = new RegExp(&#39;[&#39; + regex_lib_1.alphaNumericAndMarksCharsStr + &#39;]&#39;);
<span id='Autolinker-matcher-Url-property-openParensRe'> /**
</span> * The regular expression to match opening parenthesis in a URL match.
*
* This is to determine if we have unbalanced parenthesis in the URL, and to
* drop the final parenthesis that was matched if so.
*
* Ex: The text &quot;(check out: wikipedia.com/something_(disambiguation))&quot;
* should only autolink the inner &quot;wikipedia.com/something_(disambiguation)&quot;
* part, so if we find that we have unbalanced parenthesis, we will drop the
* last one for the match.
*
* @protected
* @property {RegExp}
*/
_this.openParensRe = /\(/g;
<span id='Autolinker-matcher-Url-property-closeParensRe'> /**
</span> * The regular expression to match closing parenthesis in a URL match. See
* {@link #openParensRe} for more information.
*
* @protected
* @property {RegExp}
*/
_this.closeParensRe = /\)/g;
_this.stripPrefix = cfg.stripPrefix;
_this.stripTrailingSlash = cfg.stripTrailingSlash;
_this.decodePercentEncoding = cfg.decodePercentEncoding;
Expand Down Expand Up @@ -186,12 +163,15 @@
if (offset &gt; 0 &amp;&amp; protocolRelativeMatch &amp;&amp; this.wordCharRegExp.test(prevChar)) {
continue;
}
// If the URL ends with a question mark, don&#39;t include the question
// mark as part of the URL. We&#39;ll assume the question mark was the
// end of a sentence, such as: &quot;Going to google.com?&quot;
if (/\?$/.test(matchStr)) {
matchStr = matchStr.substr(0, matchStr.length - 1);
}
// Handle a closing parenthesis at the end of the match, and exclude
// it if there is not a matching open parenthesis in the match
// itself.
// Handle a closing parenthesis or square bracket at the end of the
// match, and exclude it if there is not a matching open parenthesis
// or square bracket in the match itself.
if (this.matchHasUnbalancedClosingParen(matchStr)) {
matchStr = matchStr.substr(0, matchStr.length - 1); // remove the trailing &quot;)&quot;
}
Expand Down Expand Up @@ -219,32 +199,64 @@
return matches;
};
<span id='Autolinker-matcher-Url-method-matchHasUnbalancedClosingParen'> /**
</span> * Determines if a match found has an unmatched closing parenthesis. If so,
* this parenthesis will be removed from the match itself, and appended
* after the generated anchor tag.
</span> * Determines if a match found has an unmatched closing parenthesis or
* square bracket. If so, the parenthesis or square bracket will be removed
* from the match itself, and appended after the generated anchor tag.
*
* A match may have an extra closing parenthesis at the end of the match
* because the regular expression must include parenthesis for URLs such as
* &quot;wikipedia.com/something_(disambiguation)&quot;, which should be auto-linked.
*
* However, an extra parenthesis *will* be included when the URL itself is
* wrapped in parenthesis, such as in the case of &quot;(wikipedia.com/something_(disambiguation))&quot;.
* wrapped in parenthesis, such as in the case of:
* &quot;(wikipedia.com/something_(disambiguation))&quot;
* In this case, the last closing parenthesis should *not* be part of the
* URL itself, and this method will return `true`.
*
* For square brackets in URLs such as in PHP arrays, the same behavior as
* parenthesis discussed above should happen:
* &quot;[http://www.example.com/foo.php?bar[]=1&amp;bar[]=2&amp;bar[]=3]&quot;
* The closing square bracket should not be part of the URL itself, and this
* method will return `true`.
*
* @protected
* @param {String} matchStr The full match string from the {@link #matcherRegex}.
* @return {Boolean} `true` if there is an unbalanced closing parenthesis at
* the end of the `matchStr`, `false` otherwise.
* @return {Boolean} `true` if there is an unbalanced closing parenthesis or
* square bracket at the end of the `matchStr`, `false` otherwise.
*/
UrlMatcher.prototype.matchHasUnbalancedClosingParen = function (matchStr) {
var lastChar = matchStr.charAt(matchStr.length - 1);
if (lastChar === &#39;)&#39;) {
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;
if (numOpenParens &lt; numCloseParens) {
return true;
var endChar = matchStr.charAt(matchStr.length - 1);
var startChar;
if (endChar === &#39;)&#39;) {
startChar = &#39;(&#39;;
}
else if (endChar === &#39;]&#39;) {
startChar = &#39;[&#39;;
}
else {
return false; // not a close parenthesis or square bracket
}
// Find if there are the same number of open braces as close braces in
// the URL string, minus the last character (which we have already
// determined to be either &#39;)&#39; or &#39;]&#39;
var numOpenBraces = 0;
for (var i = 0, len = matchStr.length - 1; i &lt; len; i++) {
var char = matchStr.charAt(i);
if (char === startChar) {
numOpenBraces++;
}
else if (char === endChar) {
numOpenBraces = Math.max(numOpenBraces - 1, 0);
}
}
// If the number of open braces matches the number of close braces in
// the URL minus the last character, then the match has *unbalanced*
// braces because of the last character. Example of unbalanced braces
// from the regex match:
// &quot;http://example.com?a[]=1]&quot;
if (numOpenBraces === 0) {
return true;
}
return false;
};
<span id='Autolinker-matcher-Url-method-matchHasInvalidCharAfterTld'> /**
Expand Down

0 comments on commit e48391d

Please sign in to comment.