Replace deprecated URL(url) with URI(url)
This commit is contained in:
parent
f737077b1d
commit
7df1c20e82
1 changed files with 2 additions and 1 deletions
|
@ -39,6 +39,7 @@ import net.thauvin.erik.jokeapi.models.*
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
|
import java.net.URI
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.logging.Level
|
import java.util.logging.Level
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ internal fun fetchUrl(url: String, auth: String = ""): JokeResponse {
|
||||||
JokeApi.logger.fine(url)
|
JokeApi.logger.fine(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
val connection = URL(url).openConnection() as HttpURLConnection
|
val connection = URI(url).toURL().openConnection() as HttpURLConnection
|
||||||
try {
|
try {
|
||||||
connection.setRequestProperty(
|
connection.setRequestProperty(
|
||||||
"User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0"
|
"User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue