Skip to content

Commit

Permalink
Merge pull request #373 from gregjacobs/fix-tests
Browse files Browse the repository at this point in the history
Fixing tests
  • Loading branch information
gregjacobs authored Feb 27, 2022
2 parents 596348e + 329b16e commit 9b01107
Show file tree
Hide file tree
Showing 42 changed files with 360 additions and 308 deletions.
16 changes: 0 additions & 16 deletions .github/main.yml

This file was deleted.

24 changes: 8 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

workflow_dispatch:

name: run-tests
on: [push]
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Yarn install
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: yarn install
run: yarn

- name: Yarn test
run: yarn test
- name: yarn test
run: yarn test
100 changes: 59 additions & 41 deletions dist/Autolinker.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

28 changes: 14 additions & 14 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.

8 changes: 4 additions & 4 deletions docs/api/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Autolinker v3.14.3 API Docs</title>
<title>Autolinker v3.15.0 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 @@ -22,9 +22,9 @@
</head>
<body id="ext-body">

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

<div id="header-content">Autolinker v3.14.3 API Docs</div>
<div id="header-content">Autolinker v3.15.0 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 Sun 14 Mar 2021 16:46:03 by <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> 5.3.4.</div>
<div id='footer-content' style='display: none'>Generated on Sun 27 Feb 2022 11:28:05 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.Mention.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.

35 changes: 19 additions & 16 deletions docs/api/source/Autolinker.html
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,13 @@
this.sanitizeHtml = cfg.sanitizeHtml || false;
// Validate the value of the `mention` cfg
var mention = this.mention;
if (mention !== false &amp;&amp; mention !== &#39;twitter&#39; &amp;&amp; mention !== &#39;instagram&#39; &amp;&amp; mention !== &#39;soundcloud&#39;) {
throw new Error(&quot;invalid `mention` cfg - see docs&quot;);
if (mention !== false &amp;&amp; [&#39;twitter&#39;, &#39;instagram&#39;, &#39;soundcloud&#39;, &#39;tiktok&#39;].indexOf(mention) === -1) {
throw new Error(&quot;invalid `mention` cfg &#39;&quot;.concat(mention, &quot;&#39; - see docs&quot;));
}
// Validate the value of the `hashtag` cfg
var hashtag = this.hashtag;
if (hashtag !== false &amp;&amp; hashtag !== &#39;twitter&#39; &amp;&amp; hashtag !== &#39;facebook&#39; &amp;&amp; hashtag !== &#39;instagram&#39;) {
throw new Error(&quot;invalid `hashtag` cfg - see docs&quot;);
if (hashtag !== false &amp;&amp; [&#39;twitter&#39;, &#39;facebook&#39;, &#39;instagram&#39;, &#39;tiktok&#39;].indexOf(hashtag) === -1) {
throw new Error(&quot;invalid `hashtag` cfg &#39;&quot;.concat(hashtag, &quot;&#39; - see docs&quot;));
}
this.truncate = this.normalizeTruncateCfg(cfg.truncate);
this.className = cfg.className || this.className;
Expand Down Expand Up @@ -565,7 +565,7 @@
return { length: truncate, location: &#39;end&#39; };
}
else { // object, or undefined/null
return utils_1.defaults(truncate || {}, {
return (0, utils_1.defaults)(truncate || {}, {
length: Number.POSITIVE_INFINITY,
location: &#39;end&#39;
});
Expand Down Expand Up @@ -608,7 +608,7 @@
matches = [];
// Find all matches within the `textOrHtml` (but not matches that are
// already nested within &lt;a&gt;, &lt;style&gt; and &lt;script&gt; tags)
parse_html_1.parseHtml(textOrHtml, {
(0, parse_html_1.parseHtml)(textOrHtml, {
onOpenTag: function (tagName) {
if (skipTagNames.indexOf(tagName) &gt;= 0) {
skipTagsStackCount++;
Expand All @@ -623,7 +623,7 @@
// TODO: Handle HTML entities separately in parseHtml() and
// don&#39;t emit them as &quot;text&quot; except for &amp;amp; entities
var htmlCharacterEntitiesRegex = /(&amp;nbsp;|&amp;#160;|&amp;lt;|&amp;#60;|&amp;gt;|&amp;#62;|&amp;quot;|&amp;#34;|&amp;#39;)/gi;
var textSplit = utils_1.splitAndCapture(text, htmlCharacterEntitiesRegex);
var textSplit = (0, utils_1.splitAndCapture)(text, htmlCharacterEntitiesRegex);
var currentOffset_1 = offset;
textSplit.forEach(function (splitText, i) {
// even number matches are text, odd numbers are html entities
Expand Down Expand Up @@ -668,7 +668,8 @@
Autolinker.prototype.compactMatches = function (matches) {
// First, the matches need to be sorted in order of offset
matches.sort(function (a, b) { return a.getOffset() - b.getOffset(); });
for (var i = 0; i &lt; matches.length - 1; i++) {
var i = 0;
while (i &lt; matches.length - 1) {
var match = matches[i], offset = match.getOffset(), matchedTextLength = match.getMatchedText().length, endIdx = offset + matchedTextLength;
if (i + 1 &lt; matches.length) {
// Remove subsequent matches that equal offset with current match
Expand All @@ -680,8 +681,10 @@
// Remove subsequent matches that overlap with the current match
if (matches[i + 1].getOffset() &lt; endIdx) {
matches.splice(i + 1, 1);
continue;
}
}
i++;
}
return matches;
};
Expand All @@ -705,21 +708,21 @@
*/
Autolinker.prototype.removeUnwantedMatches = function (matches) {
if (!this.hashtag)
utils_1.remove(matches, function (match) { return match.getType() === &#39;hashtag&#39;; });
(0, utils_1.remove)(matches, function (match) { return match.getType() === &#39;hashtag&#39;; });
if (!this.email)
utils_1.remove(matches, function (match) { return match.getType() === &#39;email&#39;; });
(0, utils_1.remove)(matches, function (match) { return match.getType() === &#39;email&#39;; });
if (!this.phone)
utils_1.remove(matches, function (match) { return match.getType() === &#39;phone&#39;; });
(0, utils_1.remove)(matches, function (match) { return match.getType() === &#39;phone&#39;; });
if (!this.mention)
utils_1.remove(matches, function (match) { return match.getType() === &#39;mention&#39;; });
(0, utils_1.remove)(matches, function (match) { return match.getType() === &#39;mention&#39;; });
if (!this.urls.schemeMatches) {
utils_1.remove(matches, function (m) { return m.getType() === &#39;url&#39; &amp;&amp; m.getUrlMatchType() === &#39;scheme&#39;; });
(0, utils_1.remove)(matches, function (m) { return m.getType() === &#39;url&#39; &amp;&amp; m.getUrlMatchType() === &#39;scheme&#39;; });
}
if (!this.urls.wwwMatches) {
utils_1.remove(matches, function (m) { return m.getType() === &#39;url&#39; &amp;&amp; m.getUrlMatchType() === &#39;www&#39;; });
(0, utils_1.remove)(matches, function (m) { return m.getType() === &#39;url&#39; &amp;&amp; m.getUrlMatchType() === &#39;www&#39;; });
}
if (!this.urls.tldMatches) {
utils_1.remove(matches, function (m) { return m.getType() === &#39;url&#39; &amp;&amp; m.getUrlMatchType() === &#39;tld&#39;; });
(0, utils_1.remove)(matches, function (m) { return m.getType() === &#39;url&#39; &amp;&amp; m.getUrlMatchType() === &#39;tld&#39;; });
}
return matches;
};
Expand Down Expand Up @@ -884,7 +887,7 @@
*
* Ex: 0.25.1
*/
Autolinker.version = &#39;3.14.3&#39;;
Autolinker.version = &#39;3.15.0&#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
6 changes: 3 additions & 3 deletions docs/api/source/anchor-tag-builder.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@
return anchorText;
var truncateLength = truncate.length, truncateLocation = truncate.location;
if (truncateLocation === &#39;smart&#39;) {
return truncate_smart_1.truncateSmart(anchorText, truncateLength);
return (0, truncate_smart_1.truncateSmart)(anchorText, truncateLength);
}
else if (truncateLocation === &#39;middle&#39;) {
return truncate_middle_1.truncateMiddle(anchorText, truncateLength);
return (0, truncate_middle_1.truncateMiddle)(anchorText, truncateLength);
}
else {
return truncate_end_1.truncateEnd(anchorText, truncateLength);
return (0, truncate_end_1.truncateEnd)(anchorText, truncateLength);
}
};
return AnchorTagBuilder;
Expand Down
2 changes: 1 addition & 1 deletion docs/api/source/email-match.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* See this class&#39;s superclass ({@link Autolinker.match.Match}) for more details.
*/
var EmailMatch = (function (_super) {
tslib_1.__extends(EmailMatch, _super);
(0, tslib_1.__extends)(EmailMatch, _super);
<span id='Autolinker-match-Email-method-constructor'> /**
</span> * @method constructor
* @param {Object} cfg The configuration properties for the Match
Expand Down
12 changes: 6 additions & 6 deletions docs/api/source/email-matcher.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
// called multiple times, thus instantiating EmailMatcher and its RegExp
// objects each time (which is very expensive - see https://github.com/gregjacobs/Autolinker.js/issues/314).
// See descriptions of the properties where they are used for details about them
var localPartCharRegex = new RegExp(&quot;[&quot; + regex_lib_1.alphaNumericAndMarksCharsStr + &quot;!#$%&amp;&#39;*+/=?^_`{|}~-]&quot;);
var strictTldRegex = new RegExp(&quot;^&quot; + tld_regex_1.tldRegex.source + &quot;$&quot;);
var localPartCharRegex = new RegExp(&quot;[&quot;.concat(regex_lib_1.alphaNumericAndMarksCharsStr, &quot;!#$%&amp;&#39;*+/=?^_`{|}~-]&quot;));
var strictTldRegex = new RegExp(&quot;^&quot;.concat(tld_regex_1.tldRegex.source, &quot;$&quot;));
<span id='Autolinker-matcher-Email'>/**
</span> * @class Autolinker.matcher.Email
* @extends Autolinker.matcher.Matcher
Expand All @@ -42,7 +42,7 @@
* See this class&#39;s superclass ({@link Autolinker.matcher.Matcher}) for more details.
*/
var EmailMatcher = (function (_super) {
tslib_1.__extends(EmailMatcher, _super);
(0, tslib_1.__extends)(EmailMatcher, _super);
function EmailMatcher() {
var _this = _super !== null &amp;&amp; _super.apply(this, arguments) || this;
<span id='Autolinker-matcher-Email-property-localPartCharRegex'> /**
Expand Down Expand Up @@ -108,7 +108,7 @@
stateDomainDot(char);
break;
default:
utils_1.throwUnhandledCaseError(state);
(0, utils_1.throwUnhandledCaseError)(state);
}
// For debugging: search for other &quot;For debugging&quot; lines
// table.push(
Expand Down Expand Up @@ -139,7 +139,7 @@
// We&#39;ve reached the end of the &#39;mailto:&#39; prefix
if (localPartCharRegex.test(char)) {
state = 2 /* LocalPart */;
currentEmailMatch = new CurrentEmailMatch(tslib_1.__assign(tslib_1.__assign({}, currentEmailMatch), { hasMailtoPrefix: true }));
currentEmailMatch = new CurrentEmailMatch((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentEmailMatch), { hasMailtoPrefix: true }));
}
else {
// we&#39;ve matched &#39;mailto:&#39; but didn&#39;t get anything meaningful
Expand Down Expand Up @@ -258,7 +258,7 @@
// we now know that the domain part of the email is valid, and
// we have found at least a partial EmailMatch (however, the
// email address may have additional characters from this point)
currentEmailMatch = new CurrentEmailMatch(tslib_1.__assign(tslib_1.__assign({}, currentEmailMatch), { hasDomainDot: true }));
currentEmailMatch = new CurrentEmailMatch((0, tslib_1.__assign)((0, tslib_1.__assign)({}, currentEmailMatch), { hasDomainDot: true }));
}
else {
// Anything else
Expand Down
4 changes: 2 additions & 2 deletions docs/api/source/hashtag-match.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* details.
*/
var HashtagMatch = (function (_super) {
tslib_1.__extends(HashtagMatch, _super);
(0, tslib_1.__extends)(HashtagMatch, _super);
<span id='Autolinker-match-Hashtag-method-constructor'> /**
</span> * @method constructor
* @param {Object} cfg The configuration properties for the Match
Expand Down Expand Up @@ -96,7 +96,7 @@
return &#39;https://www.facebook.com/hashtag/&#39; + hashtag;
case &#39;instagram&#39;:
return &#39;https://instagram.com/explore/tags/&#39; + hashtag;
case &#39;tiktok&#39;:
case &#39;tiktok&#39;:
return &#39;https://www.tiktok.com/tag/&#39; + hashtag;
default: // Shouldn&#39;t happen because Autolinker&#39;s constructor should block any invalid values, but just in case.
throw new Error(&#39;Unknown service name to point hashtag to: &#39; + serviceName);
Expand Down
4 changes: 2 additions & 2 deletions docs/api/source/hashtag-matcher.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// called multiple times, thus instantiating HashtagMatcher and its RegExp
// objects each time (which is very expensive - see https://github.com/gregjacobs/Autolinker.js/issues/314).
// See descriptions of the properties where they are used for details about them
var matcherRegex = new RegExp(&quot;#[_&quot; + regex_lib_1.alphaNumericAndMarksCharsStr + &quot;]{1,139}(?![_&quot; + regex_lib_1.alphaNumericAndMarksCharsStr + &quot;])&quot;, &#39;g&#39;); // lookahead used to make sure we don&#39;t match something above 139 characters
var matcherRegex = new RegExp(&quot;#[_&quot;.concat(regex_lib_1.alphaNumericAndMarksCharsStr, &quot;]{1,139}(?![_&quot;).concat(regex_lib_1.alphaNumericAndMarksCharsStr, &quot;])&quot;), &#39;g&#39;); // lookahead used to make sure we don&#39;t match something above 139 characters
var nonWordCharRegex = new RegExp(&#39;[^&#39; + regex_lib_1.alphaNumericAndMarksCharsStr + &#39;]&#39;);
<span id='Autolinker-matcher-Hashtag'>/**
</span> * @class Autolinker.matcher.Hashtag
Expand All @@ -36,7 +36,7 @@
* Matcher to find HashtagMatch matches in an input string.
*/
var HashtagMatcher = (function (_super) {
tslib_1.__extends(HashtagMatcher, _super);
(0, tslib_1.__extends)(HashtagMatcher, _super);
<span id='Autolinker-matcher-Hashtag-method-constructor'> /**
</span> * @method constructor
* @param {Object} cfg The configuration properties for the Match instance,
Expand Down
4 changes: 2 additions & 2 deletions docs/api/source/html-tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
HtmlTag.prototype.addClass = function (cssClass) {
var classAttr = this.getClass(), whitespaceRegex = this.whitespaceRegex, classes = (!classAttr) ? [] : classAttr.split(whitespaceRegex), newClasses = cssClass.split(whitespaceRegex), newClass;
while (newClass = newClasses.shift()) {
if (utils_1.indexOf(classes, newClass) === -1) {
if ((0, utils_1.indexOf)(classes, newClass) === -1) {
classes.push(newClass);
}
}
Expand All @@ -224,7 +224,7 @@
HtmlTag.prototype.removeClass = function (cssClass) {
var classAttr = this.getClass(), whitespaceRegex = this.whitespaceRegex, classes = (!classAttr) ? [] : classAttr.split(whitespaceRegex), removeClasses = cssClass.split(whitespaceRegex), removeClass;
while (classes.length &amp;&amp; (removeClass = removeClasses.shift())) {
var idx = utils_1.indexOf(classes, removeClass);
var idx = (0, utils_1.indexOf)(classes, removeClass);
if (idx !== -1) {
classes.splice(idx, 1);
}
Expand Down
12 changes: 6 additions & 6 deletions docs/api/source/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
Object.defineProperty(exports, &quot;__esModule&quot;, { value: true });
exports.Autolinker = void 0;
var tslib_1 = require(&quot;tslib&quot;);
var autolinker_1 = tslib_1.__importDefault(require(&quot;./autolinker&quot;));
var autolinker_1 = (0, tslib_1.__importDefault)(require(&quot;./autolinker&quot;));
exports.Autolinker = autolinker_1.default;
exports.default = autolinker_1.default;
tslib_1.__exportStar(require(&quot;./autolinker&quot;), exports);
tslib_1.__exportStar(require(&quot;./anchor-tag-builder&quot;), exports);
tslib_1.__exportStar(require(&quot;./html-tag&quot;), exports);
tslib_1.__exportStar(require(&quot;./match/index&quot;), exports);
tslib_1.__exportStar(require(&quot;./matcher/index&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./autolinker&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./anchor-tag-builder&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./html-tag&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./match/index&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./matcher/index&quot;), exports);

//# sourceMappingURL=index.js.map
</pre>
Expand Down
12 changes: 6 additions & 6 deletions docs/api/source/index2.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<pre class="prettyprint lang-js">&quot;use strict&quot;;
Object.defineProperty(exports, &quot;__esModule&quot;, { value: true });
var tslib_1 = require(&quot;tslib&quot;);
tslib_1.__exportStar(require(&quot;./email-match&quot;), exports);
tslib_1.__exportStar(require(&quot;./hashtag-match&quot;), exports);
tslib_1.__exportStar(require(&quot;./match&quot;), exports);
tslib_1.__exportStar(require(&quot;./mention-match&quot;), exports);
tslib_1.__exportStar(require(&quot;./phone-match&quot;), exports);
tslib_1.__exportStar(require(&quot;./url-match&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./email-match&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./hashtag-match&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./match&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./mention-match&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./phone-match&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./url-match&quot;), exports);

//# sourceMappingURL=index.js.map
</pre>
Expand Down
12 changes: 6 additions & 6 deletions docs/api/source/index3.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<pre class="prettyprint lang-js">&quot;use strict&quot;;
Object.defineProperty(exports, &quot;__esModule&quot;, { value: true });
var tslib_1 = require(&quot;tslib&quot;);
tslib_1.__exportStar(require(&quot;./email-matcher&quot;), exports);
tslib_1.__exportStar(require(&quot;./hashtag-matcher&quot;), exports);
tslib_1.__exportStar(require(&quot;./matcher&quot;), exports);
tslib_1.__exportStar(require(&quot;./mention-matcher&quot;), exports);
tslib_1.__exportStar(require(&quot;./phone-matcher&quot;), exports);
tslib_1.__exportStar(require(&quot;./url-matcher&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./email-matcher&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./hashtag-matcher&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./matcher&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./mention-matcher&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./phone-matcher&quot;), exports);
(0, tslib_1.__exportStar)(require(&quot;./url-matcher&quot;), exports);

//# sourceMappingURL=index.js.map
</pre>
Expand Down
Loading

0 comments on commit 9b01107

Please sign in to comment.