mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 17:58:45 +02:00
fix(favicon): enhance variant handling in GetFavIconFromAlias function
- Added fallback logic to handle cases where the requested icon variant is unavailable. - If variant not provided, do not call WithVariant.
This commit is contained in:
@@ -81,9 +81,14 @@ func GetFavIconFromAlias(ctx context.Context, alias string, variant homepage.Ico
|
|||||||
if hp.Icon != nil {
|
if hp.Icon != nil {
|
||||||
if hp.Icon.IconSource == homepage.IconSourceRelative {
|
if hp.Icon.IconSource == homepage.IconSourceRelative {
|
||||||
result, err = homepage.FindIcon(ctx, r, *hp.Icon.FullURL)
|
result, err = homepage.FindIcon(ctx, r, *hp.Icon.FullURL)
|
||||||
|
} else if variant != homepage.IconVariantNone {
|
||||||
|
result, err = homepage.FetchFavIconFromURL(ctx, hp.Icon.WithVariant(variant))
|
||||||
|
if err != nil {
|
||||||
|
// fallback to no variant
|
||||||
|
result, err = homepage.FetchFavIconFromURL(ctx, hp.Icon.WithVariant(homepage.IconVariantNone))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
icon := hp.Icon.WithVariant(variant)
|
result, err = homepage.FetchFavIconFromURL(ctx, hp.Icon)
|
||||||
result, err = homepage.FetchFavIconFromURL(ctx, icon)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// try extract from "link[rel=icon]"
|
// try extract from "link[rel=icon]"
|
||||||
|
|||||||
Reference in New Issue
Block a user