fix: the avatar and logo URL fallback follows the configured public path
When the thumbnail fails, AvatarURL and OrganisationLogoURL answered "/" + the blob key, which skips storage.uploads.public_path_prefix and public_url (a 404 with the WinterCMS layout). They now answer the original's attach.File.URL.
This commit is contained in:
@@ -104,8 +104,13 @@ func TestAvatarURL(t *testing.T) {
|
||||
if err := attach.Publish(failing, closed); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, err := classes.AvatarURL(ctx, failing, withFile, 128); err != nil || got != "/"+attach.BlobKey(row.DiskName) {
|
||||
t.Fatalf("failing thumbnail = %q %v, want /%s", got, err, attach.BlobKey(row.DiskName))
|
||||
// The file's public URL follows storage.uploads.public_path_prefix
|
||||
// (RC-IN-03), never a bare /<key>.
|
||||
if want := attach.PublicURL(attach.BlobKey(row.DiskName)); want == "/"+attach.BlobKey(row.DiskName) {
|
||||
t.Fatalf("the public path prefix is empty (%q): the fallback is not observable", attach.PublicPathPrefix())
|
||||
}
|
||||
if got, err := classes.AvatarURL(ctx, failing, withFile, 128); err != nil || got != attach.PublicURL(attach.BlobKey(row.DiskName)) {
|
||||
t.Fatalf("failing thumbnail = %q %v, want %s", got, err, attach.PublicURL(attach.BlobKey(row.DiskName)))
|
||||
}
|
||||
|
||||
// A failing lookup is the only error.
|
||||
|
||||
Reference in New Issue
Block a user