From 8cae659ec5a066eff8ea270346dc8c1ef064f9aa Mon Sep 17 00:00:00 2001 From: Norris Oduro Date: Thu, 4 Jan 2018 18:15:50 +0000 Subject: [PATCH] Fix path regex match bug (#3686) * Fix path regex match bug * Use the escape-string-regexp package to escape regex characters * Remove redundant character escape from path * Add removed escape of backslashes --- packages/react-dev-utils/ignoredFiles.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-dev-utils/ignoredFiles.js b/packages/react-dev-utils/ignoredFiles.js index 50348ea6bdd..73a6e8bc5cf 100644 --- a/packages/react-dev-utils/ignoredFiles.js +++ b/packages/react-dev-utils/ignoredFiles.js @@ -8,12 +8,13 @@ 'use strict'; const path = require('path'); +const escape = require('escape-string-regexp'); module.exports = function ignoredFiles(appSrc) { return new RegExp( - `^(?!${path - .normalize(appSrc + '/') - .replace(/[\\]+/g, '/')}).+/node_modules/`, + `^(?!${escape( + path.normalize(appSrc + '/').replace(/[\\]+/g, '/') + )}).+/node_modules/`, 'g' ); };