From e06d28d75e7f23d02bd7b97871f28de34d16e581 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 24 Aug 2021 15:03:30 +0200 Subject: [PATCH] fixed create dir path again --- src/components/FileBrowser.tsx | 4 +++- src/functions/normalizeDirPath.ts | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/functions/normalizeDirPath.ts 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