Match distance query parameter behavior with PHP backend

This commit is contained in:
Maddie Zhan
2020-03-06 14:28:59 +08:00
parent f7ccda23e1
commit 275286cd79
6 changed files with 7 additions and 10 deletions
+2 -2
View File
@@ -143,10 +143,10 @@ func calculateDistance(clientLocation string, unit string) string {
unitString := " mi"
switch unit {
case "K":
case "km":
dist = dist * 1.609344
unitString = " km"
case "N":
case "NM":
dist = dist * 0.8684
unitString = " NM"
}
+3 -3
View File
@@ -155,7 +155,7 @@ func getIP(w http.ResponseWriter, r *http.Request) {
}
getISPInfo := r.FormValue("isp") == "true"
getDistance := r.FormValue("distance") == "true"
distanceUnit := r.FormValue("distance")
ret.ProcessedString = clientIP
@@ -174,8 +174,8 @@ func getIP(w http.ResponseWriter, r *http.Request) {
isp += ", " + ispInfo.Country
}
if ispInfo.Location != "" && getDistance {
isp += " (" + calculateDistance(ispInfo.Location, config.LoadedConfig().DistanceUnit) + ")"
if ispInfo.Location != "" {
isp += " (" + calculateDistance(ispInfo.Location, distanceUnit) + ")"
}
ret.ProcessedString += " - " + isp