fix(playlists): make the m3u parser case-insensitive again #3410
This commit is contained in:
+2
-2
@@ -162,10 +162,10 @@ func (s *playlists) parseM3U(ctx context.Context, pls *model.Playlist, baseDir s
|
|||||||
}
|
}
|
||||||
existing := make(map[string]int, len(found))
|
existing := make(map[string]int, len(found))
|
||||||
for idx := range found {
|
for idx := range found {
|
||||||
existing[found[idx].Path] = idx
|
existing[strings.ToLower(found[idx].Path)] = idx
|
||||||
}
|
}
|
||||||
for _, path := range filteredLines {
|
for _, path := range filteredLines {
|
||||||
idx, ok := existing[path]
|
idx, ok := existing[strings.ToLower(path)]
|
||||||
if ok {
|
if ok {
|
||||||
mfs = append(mfs, found[idx])
|
mfs = append(mfs, found[idx])
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -142,6 +142,20 @@ var _ = Describe("Playlists", func() {
|
|||||||
Expect(pls.Tracks[1].Path).To(Equal("test1.mp3"))
|
Expect(pls.Tracks[1].Path).To(Equal("test1.mp3"))
|
||||||
Expect(pls.Tracks[2].Path).To(Equal("test2.mp3"))
|
Expect(pls.Tracks[2].Path).To(Equal("test2.mp3"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("is case-insensitive when comparing paths", func() {
|
||||||
|
repo.data = []string{
|
||||||
|
"tEsT1.Mp3",
|
||||||
|
}
|
||||||
|
m3u := strings.Join([]string{
|
||||||
|
"TeSt1.mP3",
|
||||||
|
}, "\n")
|
||||||
|
f := strings.NewReader(m3u)
|
||||||
|
pls, err := ps.ImportM3U(ctx, f)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(pls.Tracks).To(HaveLen(1))
|
||||||
|
Expect(pls.Tracks[0].Path).To(Equal("tEsT1.Mp3"))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user