Skip to content

Commit

Permalink
fix sanitize file path while drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
prakashsvmx committed Jan 13, 2025
1 parent 656d807 commit a9de061
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ import TooltipWrapper from "../../../../Common/TooltipWrapper/TooltipWrapper";
import ListObjectsTable from "./ListObjectsTable";
import FilterObjectsSB from "../../../../ObjectBrowser/FilterObjectsSB";
import AddAccessRule from "../../../BucketDetails/AddAccessRule";
import { sanitizeFilePath } from "./utils";

const DeleteMultipleObjects = withSuspense(
React.lazy(() => import("./DeleteMultipleObjects")),
Expand Down Expand Up @@ -506,7 +507,7 @@ const ListObjects = () => {

const blobFile = new Blob([file], { type: file.type });

const filePath = get(file, "path", "");
const filePath = sanitizeFilePath(get(file, "path", ""));
const fileWebkitRelativePath = get(file, "webkitRelativePath", "");

let relativeFolderPath = folderPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,8 @@ export const displayFileIconName = (

return <IconWithLabel icon={icon} strings={splitItem} />;
};

export const sanitizeFilePath = (filePath: string) => {
// Replace `./` at the start of the path or preceded by `/` - happens when drag drop upload of files (not folders !) in chrome
return filePath.replace(/(^|\/)\.\//g, "/");
};

0 comments on commit a9de061

Please sign in to comment.