Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
prakashsvmx committed Dec 5, 2023
1 parent 3950305 commit 33553f4
Showing 1 changed file with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ import ListObjectsTable from "./ListObjectsTable";
import FilterObjectsSB from "../../../../ObjectBrowser/FilterObjectsSB";
import AddAccessRule from "../../../BucketDetails/AddAccessRule";

import sanitize from "sanitize-filename";

const DeleteMultipleObjects = withSuspense(
React.lazy(() => import("./DeleteMultipleObjects")),
);
Expand Down Expand Up @@ -524,6 +522,8 @@ const ListObjects = () => {
relativeFolderPath = fileWebkitRelativePath;
}

let prefixPath = "";

if (path !== "" || relativeFolderPath !== "") {
const finalFolderPath = relativeFolderPath
.split("/")
Expand All @@ -532,34 +532,30 @@ const ListObjects = () => {

const pathClean = path.endsWith("/") ? path.slice(0, -1) : path;

encodedPath = encodeURLString(
`${pathClean}${
!pathClean.endsWith("/") &&
finalFolderPath !== "" &&
!finalFolderPath.startsWith("/")
? "/"
: ""
}${finalFolderPath}${
!finalFolderPath.endsWith("/") ||
(finalFolderPath.trim() === "" && !path.endsWith("/"))
? "/"
: ""
}`,
);
prefixPath = `${pathClean}${
!pathClean.endsWith("/") &&
finalFolderPath !== "" &&
!finalFolderPath.startsWith("/")
? "/"
: ""
}${finalFolderPath}${
!finalFolderPath.endsWith("/") ||
(finalFolderPath.trim() === "" && !path.endsWith("/"))
? "/"
: ""
}`;
}

const sanitizedFileName = sanitize(fileName);

if (encodedPath !== "") {
uploadUrl = `${uploadUrl}?prefix=${encodedPath}${encodeURLString(
sanitizedFileName,
)}`;
} else {
if (prefixPath !== "") {
uploadUrl = `${uploadUrl}?prefix=${encodeURLString(
sanitizedFileName,
prefixPath + fileName,
)}`;
} else {
uploadUrl = `${uploadUrl}?prefix=${encodeURLString(fileName)}`;
}

encodedPath = encodeURLString(prefixPath);

const identity = encodeURLString(
`${bucketName}-${encodedPath}-${new Date().getTime()}-${Math.random()}`,
);
Expand Down

0 comments on commit 33553f4

Please sign in to comment.