Skip to content

Commit

Permalink
webserver: return on error and check if location is not nil
Browse files Browse the repository at this point in the history
  • Loading branch information
phenpessoa committed Sep 26, 2023
1 parent ef04a41 commit b5712f4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ func TibiaDataHTMLDataCollector(TibiaDataRequest TibiaDataRequestStruct) (string
case http.StatusFound:
// Check if page is in maintenance mode
location, _ := res.RawResponse.Location()
if location.Host == "maintenance.tibia.com" {
if location != nil && location.Host == "maintenance.tibia.com" {
LogMessage := "maintenance mode detected on tibia.com"
log.Printf("[info] TibiaDataHTMLDataCollector: %s!", LogMessage)
return "", validation.ErrorMaintenanceMode
Expand Down Expand Up @@ -1258,6 +1258,7 @@ func TibiaDataHTMLDataCollector(TibiaDataRequest TibiaDataRequestStruct) (string
doc, err := goquery.NewDocumentFromReader(resIo2)
if err != nil {
log.Printf("[error] TibiaDataHTMLDataCollector (URL: %s) error: %s", res.Request.URL, err)
return "", err
}

data, err := doc.Find(".Border_2 .Border_3").Html()
Expand Down

0 comments on commit b5712f4

Please sign in to comment.