centralise special path prefix check

This commit is contained in:
sentriz
2023-12-22 19:48:14 +00:00
parent 552aa3afb1
commit b5de0b3b84
3 changed files with 9 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import (
"strings"
"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/fileutil"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
)
@@ -54,7 +55,7 @@ func Lookup(dbc *db.DB, musicPaths []string, podcastsPath string, path string) (
var musicPath string
for _, mp := range musicPaths {
if strings.HasPrefix(path, filepath.Clean(mp)+string(filepath.Separator) /* ensure trailing */) {
if fileutil.HasPrefix(path, mp) {
musicPath = mp
break
}