mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-24 21:25:45 +00:00
fix(transient): scope bruno- lookup to transient base, not full path (#8273)
This commit is contained in:
committed by
GitHub
parent
36e59e992c
commit
5345cb7b5f
@@ -112,8 +112,9 @@ const getTransientScratchPrefix = () => {
|
||||
|
||||
// Check if a path is within the transient directory
|
||||
const isTransientPath = (filePath) => {
|
||||
const normalizedFilePath = path.normalize(filePath);
|
||||
const transientBase = getTransientDirectoryBase();
|
||||
return filePath.startsWith(transientBase + path.sep) || filePath.startsWith(transientBase);
|
||||
return normalizedFilePath.startsWith(transientBase + path.sep) || normalizedFilePath === transientBase;
|
||||
};
|
||||
|
||||
const envHasSecrets = (environment = {}) => {
|
||||
@@ -123,11 +124,14 @@ const envHasSecrets = (environment = {}) => {
|
||||
};
|
||||
|
||||
const findCollectionPathByItemPath = (filePath) => {
|
||||
const parts = filePath.split(path.sep);
|
||||
const index = parts.findIndex((part) => part.startsWith('bruno-'));
|
||||
const normalizedFilePath = path.normalize(filePath);
|
||||
|
||||
if (isTransientPath(filePath) && index !== -1) {
|
||||
const transientDirPath = parts.slice(0, index + 1).join(path.sep);
|
||||
if (isTransientPath(normalizedFilePath)) {
|
||||
const transientBase = getTransientDirectoryBase();
|
||||
const transientDirName = path.relative(transientBase, normalizedFilePath).split(path.sep)[0];
|
||||
if (!transientDirName) return null;
|
||||
|
||||
const transientDirPath = path.join(transientBase, transientDirName);
|
||||
const metadataPath = path.join(transientDirPath, 'metadata.json');
|
||||
try {
|
||||
const metadataContent = fs.readFileSync(metadataPath, 'utf8');
|
||||
@@ -152,9 +156,6 @@ const findCollectionPathByItemPath = (filePath) => {
|
||||
// Sort by length descending to find the most specific (deepest) match first
|
||||
const sortedPaths = allCollectionPaths.sort((a, b) => b.length - a.length);
|
||||
|
||||
// Normalize the file path for comparison
|
||||
const normalizedFilePath = path.normalize(filePath);
|
||||
|
||||
for (const collectionPath of sortedPaths) {
|
||||
const normalizedCollectionPath = path.normalize(collectionPath);
|
||||
if (normalizedFilePath.startsWith(normalizedCollectionPath + path.sep) || normalizedFilePath === normalizedCollectionPath) {
|
||||
|
||||
Reference in New Issue
Block a user