@expo/metro-file-map 57.0.4 → 57.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -308,16 +308,21 @@ function getAncestorOfRootIdx(normalPath) {
308
308
  }
309
309
  return pos / UP_FRAGMENT_SEP_LENGTH;
310
310
  }
311
+ function isAncestorPath(normalPath) {
312
+ return normalPath.split(path_1.default.sep).every((segment) => segment === '..' || segment === '');
313
+ }
311
314
  function pathsToPattern(paths, pathUtils) {
312
315
  if (paths.length === 0) {
313
316
  return null;
314
317
  }
318
+ // A normal path may not escape the matched root via further '..' indirections.
319
+ const noFurtherEscape = `(?!\\.\\.(?:\\${path_1.default.sep}|$))`;
315
320
  const pathsPatterns = paths.map((input) => {
316
321
  let pattern = pathUtils.absoluteToNormal(input);
317
322
  // When pattern is '' (root === rootDir), match any normal path that
318
323
  // doesn't escape the root via '..' indirections.
319
324
  if (pattern === '') {
320
- return `(?!\\.\\.(?:\\${path_1.default.sep}|$))`;
325
+ return noFurtherEscape;
321
326
  }
322
327
  // Append separator so that 'src' matches 'src/foo' but not 'src2'.
323
328
  if (!pattern.endsWith(path_1.default.sep)) {
@@ -325,7 +330,10 @@ function pathsToPattern(paths, pathUtils) {
325
330
  }
326
331
  // Escape all regex-special characters.
327
332
  // eslint-disable-next-line no-useless-escape
328
- return pattern.replace(/[\-\[\]\{\}\(\)\*\+\?\.\\\^\$\|\/]/g, '\\$&');
333
+ const escaped = pattern.replace(/[\-\[\]\{\}\(\)\*\+\?\.\\\^\$\|\/]/g, '\\$&');
334
+ // When the root is an ancestor of rootDir ('..', '../..'), its pattern is a
335
+ // prefix of every deeper escape ('../../x'); match only paths inside it.
336
+ return isAncestorPath(pattern) ? escaped + noFurtherEscape : escaped;
329
337
  });
330
338
  return new RegExp(`^(?:${pathsPatterns.join('|')})`);
331
339
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/metro-file-map",
3
- "version": "57.0.4",
3
+ "version": "57.0.5",
4
4
  "description": "A metro-file-map fork for Expo used with the Metro bundler",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "50ac74f1ab5682c8e32b24da6e5e97dd4dbbb80f",
43
+ "gitHead": "968a9dcec304789b2ccc1a41ef5d301938e91478",
44
44
  "scripts": {
45
45
  "build": "expo-module tsc",
46
46
  "clean": "expo-module clean",