Backend: Keep ampersand in titles generated from file names

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-07-20 13:25:09 +02:00
parent 0da72687e6
commit 2283f6019a
2 changed files with 4 additions and 1 deletions

View file

@ -7,7 +7,7 @@ import (
"github.com/photoprism/photoprism/pkg/fs"
)
var FileTitleRegexp = regexp.MustCompile("[\\p{L}\\-,':]{2,}")
var FileTitleRegexp = regexp.MustCompile("[\\p{L}\\-,':]{2,}|( & )?")
// FileTitle returns the string with the first characters of each word converted to uppercase.
func FileTitle(s string) string {

View file

@ -80,4 +80,7 @@ func TestFileTitle(t *testing.T) {
t.Run("invalid words", func(t *testing.T) {
assert.Equal(t, "", FileTitle("jg hg "))
})
t.Run("ampersand", func(t *testing.T) {
assert.Equal(t, "Coouussinen, Du & Ich", FileTitle("coouussinen, du & ich"))
})
}