Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metro-file-map

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metro-file-map - npm Package Compare versions

Comparing version 0.80.2 to 0.80.3

2

package.json
{
"name": "metro-file-map",
"version": "0.80.2",
"version": "0.80.3",
"description": "[Experimental] - 🚇 File crawling, watching and mapping for Metro",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -62,8 +62,26 @@ "use strict";

function relative(rootDir, filename) {
return filename.indexOf(rootDir + path.sep) === 0
? filename.substr(rootDir.length + 1)
: path.relative(rootDir, filename);
if (filename.indexOf(rootDir + path.sep) === 0) {
const relativePath = filename.substr(rootDir.length + 1);
// Allow any sequence of indirection fragments at the start of the path,
// e.g ../../foo, but bail out to Node's path.relative if we find a
// possible indirection after any other segment, or a leading "./".
for (let i = 0; ; i += UP_FRAGMENT_LENGTH) {
const nextIndirection = relativePath.indexOf(CURRENT_FRAGMENT, i);
if (nextIndirection === -1) {
return relativePath;
}
if (
nextIndirection !== i + 1 ||
// Fallback when ./ later in the path, or leading
relativePath[i] !== "." // and for anything other than a leading ../
) {
return path.relative(rootDir, filename);
}
}
}
return path.relative(rootDir, filename);
}
const INDIRECTION_FRAGMENT = ".." + path.sep;
const INDIRECTION_FRAGMENT_LENGTH = INDIRECTION_FRAGMENT.length;
const UP_FRAGMENT = ".." + path.sep;
const UP_FRAGMENT_LENGTH = UP_FRAGMENT.length;
const CURRENT_FRAGMENT = "." + path.sep;

@@ -75,5 +93,5 @@ // rootDir must be an absolute path and normalPath must be a normal relative

function resolve(rootDir, normalPath) {
if (normalPath.startsWith(INDIRECTION_FRAGMENT)) {
if (normalPath.startsWith(UP_FRAGMENT)) {
const dirname = rootDir === "" ? "" : path.dirname(rootDir);
return resolve(dirname, normalPath.slice(INDIRECTION_FRAGMENT_LENGTH));
return resolve(dirname, normalPath.slice(UP_FRAGMENT_LENGTH));
} else {

@@ -80,0 +98,0 @@ return (

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc