Skip to content

Commit

Permalink
Don't move files to a folder called "." when uploading them to the DAM (
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdax98 authored Nov 12, 2024
1 parent 8ffc90e commit bb9215f
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 199 deletions.
7 changes: 7 additions & 0 deletions .changeset/shaggy-rocks-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@comet/cms-admin": patch
---

Don't move files to a folder called "." when uploading them to the DAM

This bug only occurred in projects with a `react-dropzone` version >= 14.3.2.
2 changes: 1 addition & 1 deletion packages/admin/cms-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"pluralize": "^8.0.0",
"prop-types": "^15.7.2",
"react-cool-dimensions": "^2.0.0",
"react-dropzone": "^14.0.0",
"react-dropzone": "^14.3.5",
"react-final-form-arrays": "^3.1.3",
"react-hotkeys-hook": "^3.0.0",
"react-image-crop": "^8.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ const addFolderPathToFiles = async (acceptedFiles: FileWithPath[]): Promise<File

for (const file of acceptedFiles) {
let harmonizedPath: string | undefined;
// when files are uploaded via input field, the path does not have a "/" prefix
// when files are uploaded via drag and drop, the path does have a "/" prefix
// if the path has a "/" prefix, this prefix is removed => path is harmonized
if (file.path?.startsWith("/")) {
// when a file is uploaded, the file path is prefixed with "./"
// when a folder is uploaded via drag and drop, the file paths are prefixed with "/"
// when a folder is uploaded via input field, the file paths don't have any prefix
if (file.path?.startsWith("./") || file.path?.startsWith("/")) {
// if the path has a "./" or "/" prefix, this prefix is removed => path is harmonized
harmonizedPath = file.path?.split("/").splice(1).join("/");
} else {
harmonizedPath = file.path;
Expand Down
Loading

0 comments on commit bb9215f

Please sign in to comment.