From bcd1e23dd8bc345b4c2b2c617710bde20e4fa773 Mon Sep 17 00:00:00 2001 From: Nicolas Breidinger Date: Mon, 6 May 2019 15:43:34 -0700 Subject: [PATCH] Fix HasteImpl Regex (#24628) Summary: The jest HasteImpl's `pluginNameReducers` regex was not properly escaping a backslash, resulting in unintended behavior. The intent of the code is to strip the `.${name}` from the end of a filepath, where `name` is a platform name. The correct regex for that would be `^(.*)\.(myPlat)$`, but because the regex is being constructed from a string, the `\.` is being interpreted as an escaped period, resulting in the regex `^(.*).(myPlat)$`. To correct this, the backslash needs to be escaped so it makes it into the regex. [General] [Fixed] - Fix HasteImpl platform name regex Pull Request resolved: https://github.com/facebook/react-native/pull/24628 Differential Revision: D15224468 Pulled By: hramos fbshipit-source-id: 6eb507aa5410bdd7c247e6d301052d41995a2f11 --- jest/hasteImpl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest/hasteImpl.js b/jest/hasteImpl.js index 2632a105aa5..06df409167a 100644 --- a/jest/hasteImpl.js +++ b/jest/hasteImpl.js @@ -51,7 +51,7 @@ const pluginRoots /*: Array< const pluginNameReducers /*: Array< [RegExp, string], > */ = plugins.haste.platforms.map(name => [ - new RegExp(`^(.*)\.(${name})$`), + new RegExp(`^(.*)\\.(${name})$`), '$1', ]);