From f19718d46c098fd881a95b84cc72240ad40d4c05 Mon Sep 17 00:00:00 2001 From: marcobaobao Date: Fri, 26 May 2023 13:02:18 +0200 Subject: [PATCH] bugfix --- frontend/src/Archive.tsx | 8 +++++--- server/rest/handlers.go | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/src/Archive.tsx b/frontend/src/Archive.tsx index 5aa4bc6..9a4a4c9 100644 --- a/frontend/src/Archive.tsx +++ b/frontend/src/Archive.tsx @@ -56,9 +56,11 @@ export default function Downloaded() { .then(data => files$.next(data)) const fetcherSubfolder = (sub: string) => { - const folders = sub.split('/') + const folders = sub.startsWith('/') + ? sub.substring(1).split('/') + : sub.split('/') - let subdir = folders.length > 2 + const relpath = folders.length > 2 ? folders.slice(-(folders.length - 1)).join('/') : folders.pop() @@ -67,7 +69,7 @@ export default function Downloaded() { headers: { 'Content-Type': 'application/json', }, - body: JSON.stringify({ subdir: subdir }) + body: JSON.stringify({ subdir: relpath }) }) .then(res => res.json()) .then(data => { diff --git a/server/rest/handlers.go b/server/rest/handlers.go index cf4372f..e203117 100644 --- a/server/rest/handlers.go +++ b/server/rest/handlers.go @@ -123,8 +123,7 @@ func PlayFile(ctx *fiber.Ctx) error { root := config.Instance().GetConfig().DownloadPath - //TODO: further path / file validations - + // TODO: further path / file validations if strings.Contains(filepath.Dir(string(decoded)), root) { ctx.SendStatus(fiber.StatusPartialContent) return ctx.SendFile(string(decoded))