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:
2026-10-23 21:11:04 +02:00
parent b929ba9f33
commit 9730110d55
5 changed files with 37 additions and 11 deletions

View File

@@ -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.