Skip to content

Commit

Permalink
fix favicon path and try dashboard icon first then fallback to html p…
Browse files Browse the repository at this point in the history
…arsing
  • Loading branch information
yusing committed Jan 12, 2025
1 parent 137b082 commit ac6dfc8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions internal/api/v1/favicon/favicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,14 @@ func findIcon(r route.HTTPRoute, req *http.Request, uri string) (icon []byte, st
return icon, http.StatusOK, ""
}

icon, status, errMsg = findIconSlow(r, req, uri)
if icon == nil {
// fallback to dashboard icon
icon, status, errMsg = getIconAbsolute(homepage.DashboardIconBaseURL + "png/" + sanitizeName(r.TargetName()) + ".png")
icon, status, errMsg = getIconAbsolute(homepage.DashboardIconBaseURL + "png/" + sanitizeName(r.TargetName()) + ".png")
iw := r.IdlewatcherConfig()
if icon != nil && iw != nil && iw.ContainerName != "" {
icon, status, errMsg = getIconAbsolute(homepage.DashboardIconBaseURL + "png/" + sanitizeName(iw.ContainerName) + ".png")
}
if icon != nil {
// fallback to parse html
icon, status, errMsg = findIconSlow(r, req, uri)
}
// set even if error (nil)
storeIconCache(key, icon)
Expand All @@ -190,6 +194,9 @@ func findIconSlow(r route.HTTPRoute, req *http.Request, uri string) (icon []byte
defer cancel()
newReq := req.WithContext(ctx)
newReq.Header.Set("Accept-Encoding", "identity") // disable compression
if !strings.HasPrefix(uri, "/") {
uri = "/" + uri
}
u, err := url.ParseRequestURI(uri)
if err != nil {
logging.Error().Err(err).
Expand Down

0 comments on commit ac6dfc8

Please sign in to comment.