From 89fe4c97991706b8878a585681b35ff50811d443 Mon Sep 17 00:00:00 2001 From: kalvin Date: Thu, 24 Apr 2025 01:04:16 +0200 Subject: [PATCH] fix: improve CleanFilePath function to handle single-file torrents correctly --- src/torrs/helpers.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/torrs/helpers.go b/src/torrs/helpers.go index a1aff32..9cfd0d9 100644 --- a/src/torrs/helpers.go +++ b/src/torrs/helpers.go @@ -16,7 +16,10 @@ func FormatEncodedPath(filePath string) string { // CleanFilePath the file path by removing any parent directory references func CleanFilePath(path string) string { parts := strings.Split(path, "/") - // Omit the first part as it is the name of the torrent + if len(parts) <= 1 { + return path + } + // Omit the first part as it is the name of the torrent folder return strings.Join(parts[1:], "/") }