mirror of
https://github.com/librespeed/speedtest.git
synced 2024-05-10 18:54:52 +00:00
Match distance query parameter behavior with PHP backend
This commit is contained in:
+2
-2
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user