Skip to content

Commit

Permalink
fixed favicon bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zan8in committed Mar 8, 2023
1 parent 217c2cb commit 093ed9a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/favicon/favicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ func HandleFaviconHash(target, body string) (string, error) {
if len(potentialURLs) > 0 {
for _, potentialURL := range potentialURLs {
if len(potentialURL) > 0 {
if potentialURL[:2] == "//" {
if strings.HasPrefix(potentialURL, "//") {
faviconPath = "http:" + potentialURL
} else {
if potentialURL[:4] == "http" {
faviconPath = potentialURL
} else {
faviconPath = target + "/" + strings.Trim(potentialURL, "/")
}
return faviconPath, nil
} else if strings.HasPrefix(potentialURL, "http") {
faviconPath = potentialURL
return faviconPath, nil
} else if strings.HasSuffix(potentialURL, ".ico") ||
strings.HasSuffix(potentialURL, ".png") ||
strings.HasSuffix(potentialURL, ".jpg") {
faviconPath = target + "/" + strings.Trim(potentialURL, "/")
return faviconPath, nil
}
return faviconPath, nil
}
}
}
Expand Down

0 comments on commit 093ed9a

Please sign in to comment.