From 2283f6019a1e021c1a4d6344cb0c60f2f18edb17 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 20 Jul 2020 13:25:09 +0200 Subject: [PATCH] Backend: Keep ampersand in titles generated from file names Signed-off-by: Michael Mayer --- pkg/txt/file_title.go | 2 +- pkg/txt/file_title_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/txt/file_title.go b/pkg/txt/file_title.go index 8622f1d46..eea882f66 100644 --- a/pkg/txt/file_title.go +++ b/pkg/txt/file_title.go @@ -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 { diff --git a/pkg/txt/file_title_test.go b/pkg/txt/file_title_test.go index 64e5ea7ec..8f6d8199d 100644 --- a/pkg/txt/file_title_test.go +++ b/pkg/txt/file_title_test.go @@ -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")) + }) }