From b040669bfbfd1e12f0e221de5a82a7ae4225e784 Mon Sep 17 00:00:00 2001 From: Elio Date: Thu, 9 Sep 2021 19:44:10 +0200 Subject: [PATCH] Added Windows path media parsing --- src/pagesView/components/Media/Item.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pagesView/components/Media/Item.tsx b/src/pagesView/components/Media/Item.tsx index 4d9b6cf3..81815440 100644 --- a/src/pagesView/components/Media/Item.tsx +++ b/src/pagesView/components/Media/Item.tsx @@ -15,6 +15,10 @@ export const Item: React.FunctionComponent = ({media}: React.PropsWi const settings = useRecoilValue(SettingsSelector); const [ , setLightbox ] = useRecoilState(LightboxAtom); + const parseWinPath = (path: string | undefined) => { + return path?.split(`\\`).join(`/`); + } + const getFolder = () => { if (settings?.wsFolder && media.fsPath) { let relPath = media.fsPath.split(settings.wsFolder).pop(); @@ -23,7 +27,7 @@ export const Item: React.FunctionComponent = ({media}: React.PropsWi relPath = relPath.split(settings.staticFolder).pop(); } - return dirname(relPath || ""); + return dirname(parseWinPath(relPath) || ""); } return ""; }; @@ -38,7 +42,7 @@ export const Item: React.FunctionComponent = ({media}: React.PropsWi } } - Messenger.send(DashboardMessage.copyToClipboard, relPath || ""); + Messenger.send(DashboardMessage.copyToClipboard, parseWinPath(relPath) || ""); }; const calculateSize = () => { @@ -71,7 +75,7 @@ export const Item: React.FunctionComponent = ({media}: React.PropsWi

- {basename(media.fsPath)} + {basename(parseWinPath(media.fsPath) || "")}

Folder: {getFolder()}