mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Refactor string utilities into its own package str
This commit is contained in:
parent
46fc38bf61
commit
abe5690018
16 changed files with 158 additions and 125 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/utils"
|
||||
"github.com/navidrome/navidrome/utils/str"
|
||||
"github.com/pocketbase/dbx"
|
||||
)
|
||||
|
||||
|
@ -140,7 +141,7 @@ func (r *artistRepository) toModels(dba []dbArtist) model.Artists {
|
|||
}
|
||||
|
||||
func (r *artistRepository) getIndexKey(a *model.Artist) string {
|
||||
name := strings.ToLower(utils.NoArticle(a.Name))
|
||||
name := strings.ToLower(str.NoArticle(a.Name))
|
||||
for k, v := range r.indexGroups {
|
||||
key := strings.ToLower(k)
|
||||
if strings.HasPrefix(name, key) {
|
||||
|
|
|
@ -6,11 +6,11 @@ import (
|
|||
. "github.com/Masterminds/squirrel"
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/utils"
|
||||
"github.com/navidrome/navidrome/utils/str"
|
||||
)
|
||||
|
||||
func getFullText(text ...string) string {
|
||||
fullText := utils.SanitizeStrings(text...)
|
||||
fullText := str.SanitizeStrings(text...)
|
||||
return " " + fullText
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ func (r sqlRepository) doSearch(q string, offset, size int, results interface{},
|
|||
}
|
||||
|
||||
func fullTextExpr(value string) Sqlizer {
|
||||
q := utils.SanitizeStrings(value)
|
||||
q := str.SanitizeStrings(value)
|
||||
if q == "" {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue