Skip to content

Commit 4b7360a

Browse files
author
Adam Cole
committed
fix style issues, rebuild
1 parent 12ee8d8 commit 4b7360a

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

dist/Autolinker.js

Lines changed: 6 additions & 6 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: 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.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.

src/matcher/email-matcher.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ import { tldRegex } from "./tld-regex";
88
// For debugging: search for other "For debugging" lines
99
// import CliTable from 'cli-table';
1010

11-
/**
12-
* Stricter TLD regex which adds a beginning and end check to ensure
13-
* the string is a valid TLD.
14-
*/
15-
const strictTldRegex = new RegExp(`^${tldRegex.source}$`);
16-
1711
/**
1812
* @class Autolinker.matcher.Email
1913
* @extends Autolinker.matcher.Matcher
@@ -30,6 +24,12 @@ export class EmailMatcher extends Matcher {
3024
*/
3125
protected localPartCharRegex = new RegExp( `[${alphaNumericAndMarksCharsStr}!#$%&'*+/=?^_\`{|}~-]` );
3226

27+
/**
28+
* Stricter TLD regex which adds a beginning and end check to ensure
29+
* the string is a valid TLD
30+
*/
31+
protected strictTldRegex = new RegExp( `^${tldRegex.source}$` );
32+
3333
/**
3434
* Valid URI scheme for email address URLs
3535
*/
@@ -42,6 +42,7 @@ export class EmailMatcher extends Matcher {
4242
parseMatches( text: string ) {
4343
const tagBuilder = this.tagBuilder,
4444
localPartCharRegex = this.localPartCharRegex,
45+
strictTldRegex = this.strictTldRegex,
4546
mailToScheme = this.mailToScheme,
4647
matches: Match[] = [],
4748
len = text.length,
@@ -226,10 +227,10 @@ export class EmailMatcher extends Matcher {
226227
* @param {string} emailAddress - email address
227228
* @return {Boolean} - true is email have valid TLD, false otherwise
228229
*/
229-
function doesEmailHaveValidTld(emailAddress: string) {
230-
const emailAddressTld : string = emailAddress.split('.').pop() || '';
230+
function doesEmailHaveValidTld( emailAddress: string ) {
231+
const emailAddressTld : string = emailAddress.split( '.' ).pop() || '';
231232
const emailAddressNormalized = emailAddressTld.toLowerCase();
232-
const isValidTld = strictTldRegex.test(emailAddressNormalized);
233+
const isValidTld = strictTldRegex.test( emailAddressNormalized );
233234

234235
return isValidTld;
235236
}
@@ -265,7 +266,7 @@ export class EmailMatcher extends Matcher {
265266
}
266267

267268
// if the email address has a valid TLD, add it to the list of matches
268-
if (doesEmailHaveValidTld(emailAddress)) {
269+
if ( doesEmailHaveValidTld( emailAddress ) ) {
269270
matches.push( new EmailMatch( {
270271
tagBuilder : tagBuilder,
271272
matchedText : matchedText,

0 commit comments

Comments
 (0)