mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-03 04:29:09 +01:00
fix: handle Windows paths in cloneItem and getDirectoryName functions
This commit is contained in:
parent
57d86eb118
commit
8ddaaf378a
@ -21,7 +21,7 @@ import {
|
|||||||
transformRequestToSaveToFilesystem
|
transformRequestToSaveToFilesystem
|
||||||
} from 'utils/collections';
|
} from 'utils/collections';
|
||||||
import { uuid, waitForNextTick } from 'utils/common';
|
import { uuid, waitForNextTick } from 'utils/common';
|
||||||
import { PATH_SEPARATOR, getDirectoryName } from 'utils/common/platform';
|
import { PATH_SEPARATOR, getDirectoryName, isWindowsPath } from 'utils/common/platform';
|
||||||
import { cancelNetworkRequest, sendNetworkRequest } from 'utils/network';
|
import { cancelNetworkRequest, sendNetworkRequest } from 'utils/network';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -494,7 +494,7 @@ export const cloneItem = (newName, itemUid, collectionUid) => (dispatch, getStat
|
|||||||
);
|
);
|
||||||
if (!reqWithSameNameExists) {
|
if (!reqWithSameNameExists) {
|
||||||
const dirname = getDirectoryName(item.pathname);
|
const dirname = getDirectoryName(item.pathname);
|
||||||
const fullName = path.join(dirname, filename);
|
const fullName = isWindowsPath(item.pathname) ? path.win32.join(dirname, filename) : path.join(dirname, filename);
|
||||||
const { ipcRenderer } = window;
|
const { ipcRenderer } = window;
|
||||||
const requestItems = filter(parentItem.items, (i) => i.type !== 'folder');
|
const requestItems = filter(parentItem.items, (i) => i.type !== 'folder');
|
||||||
itemToSave.seq = requestItems ? requestItems.length + 1 : 1;
|
itemToSave.seq = requestItems ? requestItems.length + 1 : 1;
|
||||||
|
@ -24,11 +24,28 @@ export const getSubdirectoriesFromRoot = (rootPath, pathname) => {
|
|||||||
return relativePath ? relativePath.split(path.sep) : [];
|
return relativePath ? relativePath.split(path.sep) : [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const isWindowsPath = (pathname) => {
|
||||||
|
|
||||||
|
if (!isWindowsOS()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for Windows drive letter format (e.g., "C:\")
|
||||||
|
const hasDriveLetter = /^[a-zA-Z]:\\/.test(pathname);
|
||||||
|
|
||||||
|
// Check for UNC path format (e.g., "\\server\share") a.k.a. network path || WSL path
|
||||||
|
const isUNCPath = pathname.startsWith('\\\\');
|
||||||
|
|
||||||
|
return hasDriveLetter || isUNCPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
export const getDirectoryName = (pathname) => {
|
export const getDirectoryName = (pathname) => {
|
||||||
// convert to unix style path
|
// convert to unix style path
|
||||||
pathname = slash(pathname);
|
// pathname = slash(pathname);
|
||||||
|
|
||||||
return path.dirname(pathname);
|
return isWindowsPath(pathname) ? path.win32.dirname(pathname) : path.dirname(pathname);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isWindowsOS = () => {
|
export const isWindowsOS = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user