assert,util: compare RegExp.lastIndex while using deep equal checks · nodejs/node@dab8ab2 · GitHub
Skip to content

Commit dab8ab2

Browse files
authored
assert,util: compare RegExp.lastIndex while using deep equal checks
Compare the `lastIndex` property of regular expressions next to the flags and source property. Fixes: #28766 Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de> PR-URL: #41020 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
1 parent 34fdea1 commit dab8ab2

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

doc/api/assert.md

Lines changed: 10 additions & 0 deletions

lib/internal/util/comparisons.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ const kIsMap = 3;
6363

6464
// Check if they have the same source and flags
6565
function areSimilarRegExps(a, b) {
66-
return a.source === b.source && a.flags === b.flags;
66+
return a.source === b.source &&
67+
a.flags === b.flags &&
68+
a.lastIndex === b.lastIndex;
6769
}
6870

6971
function areSimilarFloatArrays(a, b) {

test/parallel/test-assert-deep.js

Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)