Skip to content

Commit b04d11c

Browse files
authored
webserver: return on error and check if location is not nil (#257)
1 parent ef04a41 commit b04d11c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/webserver.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ func TibiaDataHTMLDataCollector(TibiaDataRequest TibiaDataRequestStruct) (string
12301230
case http.StatusFound:
12311231
// Check if page is in maintenance mode
12321232
location, _ := res.RawResponse.Location()
1233-
if location.Host == "maintenance.tibia.com" {
1233+
if location != nil && location.Host == "maintenance.tibia.com" {
12341234
LogMessage := "maintenance mode detected on tibia.com"
12351235
log.Printf("[info] TibiaDataHTMLDataCollector: %s!", LogMessage)
12361236
return "", validation.ErrorMaintenanceMode
@@ -1258,6 +1258,7 @@ func TibiaDataHTMLDataCollector(TibiaDataRequest TibiaDataRequestStruct) (string
12581258
doc, err := goquery.NewDocumentFromReader(resIo2)
12591259
if err != nil {
12601260
log.Printf("[error] TibiaDataHTMLDataCollector (URL: %s) error: %s", res.Request.URL, err)
1261+
return "", err
12611262
}
12621263

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

0 commit comments

Comments
 (0)