Skip to content

Commit b120c6d

Browse files
committed
Update a few comments and add profile script
1 parent 7b23911 commit b120c6d

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"lint": "eslint src tests scripts",
2323
"lint:fix": "npm run lint -- --fix",
2424
"prepublishOnly": "npm-run-all build test",
25+
"profile": "node --inspect --require ts-node/register benchmarks/profile.ts",
2526
"start": "webpack serve --open",
2627
"test": "npm-run-all test:unit test:integration",
2728
"test:ci": "npm-run-all coverage test:integration",

src/parser/parse-matches.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,17 +1164,11 @@ function captureMatchIfValidAndRemove(context: ParseMatchesContext, stateMachine
11641164
case StateMachineType.Url: {
11651165
// We don't want to accidentally match a URL that is preceded by an
11661166
// '@' character, which would be an email address
1167-
const charBeforeUrlMatch = text.charAt(stateMachine.startIdx - 1);
1168-
if (charBeforeUrlMatch === '@') {
1167+
const charBeforeUrlMatch = text.charCodeAt(stateMachine.startIdx - 1);
1168+
if (charBeforeUrlMatch === Char.AtSign /* '@' */) {
11691169
return;
11701170
}
11711171

1172-
// For the purpose of this parser, we've generalized 'www'
1173-
// matches as part of 'tld' matches. However, for backward
1174-
// compatibility, we distinguish beween TLD matches and matches
1175-
// that begin with 'www.' so that users may turn off 'www'
1176-
// matches. As such, we need to correct for that now if the
1177-
// URL begins with 'www.'
11781172
switch (stateMachine.matchType) {
11791173
case UrlStateMachineMatchType.Scheme: {
11801174
// Autolinker accepts many characters in a url's scheme (like `fake://test.com`).

src/parser/uri-utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ export function isValidTldMatch(url: string): boolean {
205205
}
206206

207207
// Regular expression to confirm a valid IPv4 address (ex: '192.168.0.1')
208+
// TODO: encode this into the state machine so that we don't need to run this
209+
// regexp separately to confirm the match
208210
const ipV4Re =
209211
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
210212

0 commit comments

Comments
 (0)