From bf6c79ad67dcebce36d3b6bcfc378e8a3d9a1fbe Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 20 Jul 2020 13:30:25 +0200 Subject: [PATCH] Backend: Keep plus 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 eea882f66..d578e3ee3 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 8f6d8199d..0faa8d7b2 100644 --- a/pkg/txt/file_title_test.go +++ b/pkg/txt/file_title_test.go @@ -83,4 +83,7 @@ func TestFileTitle(t *testing.T) { t.Run("ampersand", func(t *testing.T) { assert.Equal(t, "Coouussinen, Du & Ich", FileTitle("coouussinen, du & ich")) }) + t.Run("plus", func(t *testing.T) { + assert.Equal(t, "Foo+Bar, Du + Ich & Er", FileTitle("Foo+bar, du + ich & er +")) + }) }