Config: Remove slash from social preview image file path #3160

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2023-02-02 17:13:12 +01:00
parent a3ee21897d
commit 2e7268f834
2 changed files with 6 additions and 2 deletions

View file

@ -463,7 +463,7 @@ func (c *Config) SitePreview() string {
}
if !strings.HasPrefix(c.options.SitePreview, "http") {
return c.SiteUrl() + c.options.SitePreview
return c.SiteUrl() + strings.TrimPrefix(c.options.SitePreview, "/")
}
return c.options.SitePreview

View file

@ -452,11 +452,15 @@ func TestConfig_SiteDomain(t *testing.T) {
func TestConfig_SitePreview(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, "http://photoprism.me:2342/static/img/preview.jpg", c.SitePreview())
assert.Equal(t, "https://i.photoprism.app/prism?cover=64&style=centered%20dark&caption=none&title=PhotoPrism", c.SitePreview())
c.options.SitePreview = "http://preview.jpg"
assert.Equal(t, "http://preview.jpg", c.SitePreview())
c.options.SitePreview = "preview123.jpg"
assert.Equal(t, "http://photoprism.me:2342/preview123.jpg", c.SitePreview())
c.options.SitePreview = "foo/preview123.jpg"
assert.Equal(t, "http://photoprism.me:2342/foo/preview123.jpg", c.SitePreview())
c.options.SitePreview = "/foo/preview123.jpg"
assert.Equal(t, "http://photoprism.me:2342/foo/preview123.jpg", c.SitePreview())
}
func TestConfig_SiteTitle(t *testing.T) {