This commit is contained in:
2023-05-26 13:02:18 +02:00
parent 1e0e625d1a
commit f19718d46c
2 changed files with 6 additions and 5 deletions

View File

@@ -56,9 +56,11 @@ export default function Downloaded() {
.then(data => files$.next(data)) .then(data => files$.next(data))
const fetcherSubfolder = (sub: string) => { 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.slice(-(folders.length - 1)).join('/')
: folders.pop() : folders.pop()
@@ -67,7 +69,7 @@ export default function Downloaded() {
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ subdir: subdir }) body: JSON.stringify({ subdir: relpath })
}) })
.then(res => res.json()) .then(res => res.json())
.then(data => { .then(data => {

View File

@@ -124,7 +124,6 @@ func PlayFile(ctx *fiber.Ctx) error {
root := config.Instance().GetConfig().DownloadPath root := config.Instance().GetConfig().DownloadPath
// TODO: further path / file validations // TODO: further path / file validations
if strings.Contains(filepath.Dir(string(decoded)), root) { if strings.Contains(filepath.Dir(string(decoded)), root) {
ctx.SendStatus(fiber.StatusPartialContent) ctx.SendStatus(fiber.StatusPartialContent)
return ctx.SendFile(string(decoded)) return ctx.SendFile(string(decoded))