Skip to content

Commit 7b4c520

Browse files
authored
chore: clean up rules (#3791)
1 parent 09577e5 commit 7b4c520

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/rules.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ const reflinkSearch = edit('reflink|nolink(?!\\()', 'g')
358358
.replace('nolink', nolink)
359359
.getRegex();
360360

361+
const _caseInsensitiveProtocol = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
362+
361363
/**
362364
* Normal Inline Grammar
363365
*/
@@ -409,13 +411,13 @@ const inlineGfm: Record<InlineKeys, RegExp> = {
409411
emStrongRDelimAst: emStrongRDelimAstGfm,
410412
emStrongLDelim: emStrongLDelimGfm,
411413
url: edit(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/)
412-
.replace('protocol', /[fF][tT][pP]|[hH][tT][tT][pP][sS]?/)
414+
.replace('protocol', _caseInsensitiveProtocol)
413415
.replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/)
414416
.getRegex(),
415417
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
416418
del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
417419
text: edit(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/)
418-
.replace('protocol', /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/)
420+
.replace('protocol', _caseInsensitiveProtocol)
419421
.getRegex(),
420422
};
421423

0 commit comments

Comments
 (0)