Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: now checks for slash and backslash when renaming storage folder

Jonathan Summers-Muirfd440234d454
diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.js
index 970d867b712..9824cb92293 100644
--- a/studio/localStores/storageExplorer/StorageExplorerStore.js
+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js
@@ -286,6 +286,9 @@ class StorageExplorerStore {
if (isNull(formattedName)) {
return
}
+ /**
+ * todo: move this to a util file, as renameFolder() uses same logic
+ */
if (formattedName.includes('/') || formattedName.includes('\\')) {
return toast.error('Folder names should not have forward or back slashes.')
}
@@ -1087,11 +1090,25 @@ class StorageExplorerStore {
renameFolder = async (folder, newName, columnIndex) => {
const originalName = folder.name
+
+ /**
+ * Catch any folder names that contain slash or backslash
+ *
+ * this is because slashes are used to denote
+ * children/parent relationships in bucket
+ *
+ * todo: move this to a util file, as createFolder() uses same logic
+ */
+ if (newName.includes('/') || newName.includes('\\')) {
+ return toast.error('Folder names should not have forward or back slashes.')
+ }
+
if (originalName === newName) {
this.updateRowStatus(originalName, STORAGE_ROW_STATUS.READY, columnIndex)
} else {
this.updateRowStatus(originalName, STORAGE_ROW_STATUS.LOADING, columnIndex, newName)
const files = await this.getAllItemsAlongFolder(folder)
+
// Make this batched promises into a reusable function for storage, i think this will be super helpful
const promises = files.map((file) => {
const fromPath = `${file.prefix}/${file.name}`