Skip to content

Commit 3b59e81

Browse files
refactor: use strict equality in RegExp exec checks (#3935)
1 parent e6b37f2 commit 3b59e81

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/Lexer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export class _Lexer<ParserOutput = string, RendererOutput = string> {
307307
if (this.tokens.links) {
308308
const links = Object.keys(this.tokens.links);
309309
if (links.length > 0) {
310-
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
310+
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) !== null) {
311311
if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
312312
maskedSrc = maskedSrc.slice(0, match.index)
313313
+ '[' + 'a'.repeat(match[0].length - 2) + ']'
@@ -318,13 +318,13 @@ export class _Lexer<ParserOutput = string, RendererOutput = string> {
318318
}
319319

320320
// Mask out escaped characters
321-
while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
321+
while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) !== null) {
322322
maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
323323
}
324324

325325
// Mask out other blocks
326326
let offset;
327-
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
327+
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) !== null) {
328328
offset = match[2] ? match[2].length : 0;
329329
maskedSrc = maskedSrc.slice(0, match.index + offset) + '[' + 'a'.repeat(match[0].length - offset - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
330330
}

src/Tokenizer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
748748
// Clip maskedSrc to same section of string as src (move to lexer?)
749749
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
750750

751-
while ((match = endReg.exec(maskedSrc)) != null) {
751+
while ((match = endReg.exec(maskedSrc)) !== null) {
752752
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
753753

754754
if (!rDelim) continue; // skip single * in __abc*abc__
@@ -842,7 +842,7 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
842842
// Clip maskedSrc to same section of string as src
843843
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
844844

845-
while ((match = endReg.exec(maskedSrc)) != null) {
845+
while ((match = endReg.exec(maskedSrc)) !== null) {
846846
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
847847

848848
if (!rDelim) continue;

0 commit comments

Comments
 (0)