diff --git a/src/components/FileBrowser.tsx b/src/components/FileBrowser.tsx index 0dc24ea..84f6d84 100644 --- a/src/components/FileBrowser.tsx +++ b/src/components/FileBrowser.tsx @@ -1,6 +1,7 @@ import React from "react" import { useState } from "react" import { useContextMenu } from "react-contexify" +import normalizeDirPath from "../functions/normalizeDirPath" import uploadFile from "../functions/uploadFile" import { useCopyMutation, useCreateDirMutation, useDeleteDirMutation, useDeleteFileMutation, useMoveMutation, useOpenDirQuery } from "../generated/graphql" import Breadcrum from "./Breadcrum" @@ -117,7 +118,8 @@ const FileBrowser: React.FC = () => {
{ - await createDirMutation({variables:{path:path + dirName}}) + const fullPath = normalizeDirPath(normalizeDirPath(path) + dirName) + await createDirMutation({variables:{path: fullPath}}) refetchDir() }} /> diff --git a/src/functions/normalizeDirPath.ts b/src/functions/normalizeDirPath.ts new file mode 100644 index 0000000..6168444 --- /dev/null +++ b/src/functions/normalizeDirPath.ts @@ -0,0 +1,5 @@ +function normalizeDirPath(path:string): string { + return path.endsWith("/")?path: (path + "/") +} + +export default normalizeDirPath