mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: window normlize path comparison (#7240)
This commit is contained in:
@@ -36,14 +36,14 @@ const isBrunoConfigFile = (pathname, collectionPath) => {
|
||||
const dirname = path.dirname(pathname);
|
||||
const basename = path.basename(pathname);
|
||||
|
||||
return dirname === collectionPath && basename === 'bruno.json';
|
||||
return path.normalize(dirname) === path.normalize(collectionPath) && basename === 'bruno.json';
|
||||
};
|
||||
|
||||
const isEnvironmentsFolder = (pathname, collectionPath) => {
|
||||
const dirname = path.dirname(pathname);
|
||||
const envDirectory = path.join(collectionPath, 'environments');
|
||||
|
||||
return dirname === envDirectory;
|
||||
return path.normalize(dirname) === path.normalize(envDirectory);
|
||||
};
|
||||
|
||||
const isFolderRootFile = (pathname, collectionPath) => {
|
||||
@@ -64,7 +64,7 @@ const isCollectionRootFile = (pathname, collectionPath) => {
|
||||
const basename = path.basename(pathname);
|
||||
|
||||
// return if we are not at the root of the collection
|
||||
if (dirname !== collectionPath) {
|
||||
if (path.normalize(dirname) !== path.normalize(collectionPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ const add = async (win, pathname, collectionUid, collectionPath, useWorkerThread
|
||||
const addDirectory = async (win, pathname, collectionUid, collectionPath) => {
|
||||
const envDirectory = path.join(collectionPath, 'environments');
|
||||
|
||||
if (pathname === envDirectory) {
|
||||
if (path.normalize(pathname) === path.normalize(envDirectory)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@ const unlink = (win, pathname, collectionUid, collectionPath) => {
|
||||
const basename = path.basename(pathname);
|
||||
const dirname = path.dirname(pathname);
|
||||
|
||||
if (basename === 'opencollection.yml' && dirname === collectionPath) {
|
||||
if (basename === 'opencollection.yml' && path.normalize(dirname) === path.normalize(collectionPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -581,7 +581,7 @@ const unlink = (win, pathname, collectionUid, collectionPath) => {
|
||||
const unlinkDir = async (win, pathname, collectionUid, collectionPath) => {
|
||||
const envDirectory = path.join(collectionPath, 'environments');
|
||||
|
||||
if (pathname === envDirectory) {
|
||||
if (path.normalize(pathname) === path.normalize(envDirectory)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,8 +114,12 @@ 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) {
|
||||
if (filePath.startsWith(collectionPath + path.sep) || filePath === collectionPath) {
|
||||
const normalizedCollectionPath = path.normalize(collectionPath);
|
||||
if (normalizedFilePath.startsWith(normalizedCollectionPath + path.sep) || normalizedFilePath === normalizedCollectionPath) {
|
||||
return collectionPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ const isDotEnvFile = (pathname, collectionPath) => {
|
||||
const dirname = path.dirname(pathname);
|
||||
const basename = path.basename(pathname);
|
||||
|
||||
return dirname === collectionPath && basename === '.env';
|
||||
return path.normalize(dirname) === path.normalize(collectionPath) && basename === '.env';
|
||||
};
|
||||
|
||||
const isValidDotEnvFilename = (filename) => {
|
||||
@@ -456,7 +456,7 @@ const isBrunoConfigFile = (pathname, collectionPath) => {
|
||||
const dirname = path.dirname(pathname);
|
||||
const basename = path.basename(pathname);
|
||||
|
||||
return dirname === collectionPath && basename === 'bruno.json';
|
||||
return path.normalize(dirname) === path.normalize(collectionPath) && basename === 'bruno.json';
|
||||
};
|
||||
|
||||
const isBruEnvironmentConfig = (pathname, collectionPath) => {
|
||||
@@ -464,14 +464,14 @@ const isBruEnvironmentConfig = (pathname, collectionPath) => {
|
||||
const envDirectory = path.join(collectionPath, 'environments');
|
||||
const basename = path.basename(pathname);
|
||||
|
||||
return dirname === envDirectory && hasBruExtension(basename);
|
||||
return path.normalize(dirname) === path.normalize(envDirectory) && hasBruExtension(basename);
|
||||
};
|
||||
|
||||
const isCollectionRootBruFile = (pathname, collectionPath) => {
|
||||
const dirname = path.dirname(pathname);
|
||||
const basename = path.basename(pathname);
|
||||
|
||||
return dirname === collectionPath && basename === 'collection.bru';
|
||||
return path.normalize(dirname) === path.normalize(collectionPath) && basename === 'collection.bru';
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user