refill api url when left empty (#1267)

This commit is contained in:
leekleak 2025-02-10 21:07:12 +02:00 committed by GitHub
parent d97811d4e8
commit 57587be9be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -74,7 +74,9 @@ class LocationSearchSettings internal constructor(
fun setOverpassUrl(overpassUrl: String?) { fun setOverpassUrl(overpassUrl: String?) {
var url = overpassUrl var url = overpassUrl
if (url != null) { if (url.isNullOrBlank()) {
url = DefaultOverpassUrl
} else {
if (!url.startsWith("http://") && !url.startsWith("https://")) { if (!url.startsWith("http://") && !url.startsWith("https://")) {
url = "https://$url" url = "https://$url"
} }
@ -95,7 +97,9 @@ class LocationSearchSettings internal constructor(
fun setTileServer(tileServer: String?) { fun setTileServer(tileServer: String?) {
var url = tileServer var url = tileServer
if (url != null) { if (url.isNullOrBlank()) {
url = DefaultTileServerUrl
} else {
if (!url.startsWith("http://") && !url.startsWith("https://")) { if (!url.startsWith("http://") && !url.startsWith("https://")) {
url = "https://$url" url = "https://$url"
} }
@ -136,8 +140,8 @@ class LocationSearchSettings internal constructor(
} }
companion object { companion object {
const val DefaultTileServerUrl = "https://tile.openstreetmap.org" const val DefaultTileServerUrl = "https://tile.openstreetmap.org/\${z}/\${x}/\${y}.png"
const val DefaultOverpassUrl = "https://overpass-api.de/" const val DefaultOverpassUrl = "https://overpass-api.de"
} }
} }