Added note about Privacy Redirect
Disabled maps redirects by default due to bugs
Added timeout to osm web request
Closes https://github.com/libredirect/libredirect/issues/485
This commit is contained in:
Hygna 2022-10-29 12:46:53 +01:00
parent 70301fc8b5
commit 73cc5ce38d
No known key found for this signature in database
3 changed files with 23 additions and 10 deletions

View File

@ -183,16 +183,25 @@ function redirect(url, type, initiator, forceRedirection) {
function addressToLatLng(address) {
const xmlhttp = new XMLHttpRequest()
xmlhttp.open("GET", `https://nominatim.openstreetmap.org/search/${address}?format=json&limit=1`, false)
xmlhttp.send()
if (xmlhttp.status === 200) {
const json = JSON.parse(xmlhttp.responseText)[0]
if (json) {
console.log("json", json)
return [`${json.lat},${json.lon}`, `${json.boundingbox[2]},${json.boundingbox[1]},${json.boundingbox[3]},${json.boundingbox[0]}`]
}
xmlhttp.timeout = 5000
http.ontimeout = () => {
return
}
console.info("Error: Status is " + xmlhttp.status)
http.onerror = () => {
return
}
xmlhttp.send()
http.onreadystatechange = () => {
if (xmlhttp.status === 200) {
const json = JSON.parse(xmlhttp.responseText)[0]
if (json) {
console.log("json", json)
return [`${json.lat},${json.lon}`, `${json.boundingbox[2]},${json.boundingbox[1]},${json.boundingbox[3]},${json.boundingbox[0]}`]
}
}
console.info("Error: Status is " + xmlhttp.status)
}
xmlhttp.open("GET", `https://nominatim.openstreetmap.org/search/${address}?format=json&limit=1`, false)
}
let mapCentre = "#"

View File

@ -579,7 +579,7 @@
"targets": ["^https?:\\/{2}maps\\.libredirect\\.invalid", "^https?:\\/{2}(((www|maps)\\.)?(google\\.).*(\\/maps)|maps\\.(google\\.).*)"],
"name": "Maps",
"options": {
"enabled": true,
"enabled": false,
"frontend": "osm"
},
"imageType": "svgMono",

View File

@ -20,5 +20,9 @@
<h4>Source Code:</h4>
<h4><a href='https://libredirect.codeberg.page/source_code'>https://libredirect.codeberg.page/source_code</a></h4>
</div>
<div class="some-block option-block">
<h4>Forked from:</h4>
<h4><a href="https://github.com/SimonBrazell/privacy-redirect">Privacy Redirect</a></h4>
</div>
</div>
</section>