Draw processed string in share PNG when ISP info is not available

This commit is contained in:
Maddie Zhan 2020-03-05 22:10:24 +08:00
parent 8e3b747195
commit f7ccda23e1

View file

@ -321,12 +321,16 @@ func DrawPNG(w http.ResponseWriter, r *http.Request) {
drawer.Face = orgFace
drawer.Src = colorISP
drawer.Dot = freetype.Pt(6, canvasHeight-ctx.PointToFixed(14).Round()-15)
removeRegexp := regexp.MustCompile(`AS\d+\s`)
org := removeRegexp.ReplaceAllString(result.RawISPInfo.Organization, "")
if result.RawISPInfo.Country != "" {
org += ", " + result.RawISPInfo.Country
if result.RawISPInfo.Organization != "" {
removeRegexp := regexp.MustCompile(`AS\d+\s`)
org := removeRegexp.ReplaceAllString(result.RawISPInfo.Organization, "")
if result.RawISPInfo.Country != "" {
org += ", " + result.RawISPInfo.Country
}
drawer.DrawString(org)
} else {
drawer.DrawString(result.ProcessedString)
}
drawer.DrawString(org)
w.Header().Set("Content-Disposition", "inline; filename="+uuid+".png")
w.Header().Set("Content-Type", "image/png")