Skip to content

Commit 39615e2

Browse files
committed
Fix regex detection
1 parent 8ef93ff commit 39615e2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
var array = require('isarray');
4+
var regexp = require('is-regex');
45
var visit = require('unist-util-visit-parents');
56
var is = require('hast-util-is-element');
67
var escape = require('escape-string-regexp');
@@ -15,7 +16,7 @@ function findAndReplace(tree, find, replace, options) {
1516
var settings;
1617
var schema;
1718

18-
if (typeof find === 'string' || (typeof find === 'object' && 'flags' in find)) {
19+
if (typeof find === 'string' || regexp(find)) {
1920
schema = [[find, replace]];
2021
} else {
2122
schema = find;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"dependencies": {
2424
"escape-string-regexp": "^1.0.5",
2525
"hast-util-is-element": "^1.0.0",
26+
"is-regex": "^1.0.3",
2627
"isarray": "^2.0.1",
2728
"unist-util-visit-parents": "^1.1.0"
2829
},

0 commit comments

Comments
 (0)