From 7aca4aa8d0de74e01b1d3006837b103073c990c3 Mon Sep 17 00:00:00 2001 From: Filipp Riabchun Date: Tue, 9 Feb 2021 18:45:44 +0200 Subject: [PATCH] Use a safer check for RegExp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There’s a proposal for `Array#lastIndex` which may cause a false positive: https://github.com/tc39/proposal-array-last see https://github.com/syntax-tree/mdast-util-find-and-replace/commit/536e7e5d23efd16dffb96fb0148eda922636940e#r46933368 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index d34516c..037add9 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,7 @@ function findAndReplace(tree, find, replace, options) { if ( typeof find === 'string' || - (find && typeof find.lastIndex === 'number') + (find && typeof find.exec === 'function') ) { schema = [[find, replace]] } else {