mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-02 00:21:14 +03:00
Allow searching songs by filepath, for songs without Title
This commit is contained in:
parent
47872c9e8a
commit
e8d0f2ec2c
@ -11,7 +11,8 @@ import (
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
)
|
||||
|
||||
var quotesRegex = regexp.MustCompile("[“”‘’'\"\\[\\(\\{\\]\\)\\}]")
|
||||
var quotesRegex = regexp.MustCompile("[“”‘’'\"\\[({\\])}]")
|
||||
var slashRemover = strings.NewReplacer("\\", " ", "/", " ")
|
||||
|
||||
func SanitizeStrings(text ...string) string {
|
||||
sanitizedText := strings.Builder{}
|
||||
@ -25,6 +26,7 @@ func SanitizeStrings(text ...string) string {
|
||||
var fullText []string
|
||||
for w := range words {
|
||||
w = quotesRegex.ReplaceAllString(w, "")
|
||||
w = slashRemover.Replace(w)
|
||||
if w != "" {
|
||||
fullText = append(fullText, w)
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ var _ = Describe("Sanitize Strings", func() {
|
||||
It("remove opening brackets", func() {
|
||||
Expect(str.SanitizeStrings("[Five Years]")).To(Equal("five years"))
|
||||
})
|
||||
It("remove slashes", func() {
|
||||
Expect(str.SanitizeStrings("folder/file\\yyyy")).To(Equal("folder file yyyy"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("SanitizeFieldForSorting", func() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user