Removing more warnings
This commit is contained in:
+9
-3
@@ -21,7 +21,7 @@
|
||||
package com.vitorpamplona.amethyst.commons.preview
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
|
||||
@Immutable
|
||||
class UrlInfoItem(
|
||||
@@ -31,10 +31,16 @@ class UrlInfoItem(
|
||||
val image: String = "",
|
||||
val mimeType: String,
|
||||
) {
|
||||
val verifiedUrl = runCatching { URL(url) }.getOrNull()
|
||||
val verifiedUrl = runCatching { URI(url).toURL() }.getOrNull()
|
||||
val imageUrlFullPath =
|
||||
if (image.startsWith("/")) {
|
||||
URL(verifiedUrl, image).toString()
|
||||
runCatching {
|
||||
verifiedUrl
|
||||
?.toURI()
|
||||
?.resolve(image)
|
||||
?.toURL()
|
||||
?.toString()
|
||||
}.getOrNull() ?: image
|
||||
} else {
|
||||
image
|
||||
}
|
||||
|
||||
+9
-3
@@ -40,8 +40,8 @@ import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableMap
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import java.net.MalformedURLException
|
||||
import java.net.URI
|
||||
import java.net.URISyntaxException
|
||||
import java.net.URL
|
||||
import kotlin.coroutines.cancellation.CancellationException
|
||||
|
||||
class RichTextParser {
|
||||
@@ -424,12 +424,18 @@ class RichTextParser {
|
||||
|
||||
fun isValidURL(url: String?): Boolean =
|
||||
try {
|
||||
URL(url).toURI()
|
||||
true
|
||||
if (url != null) {
|
||||
URI(url).toURL()
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} catch (e: MalformedURLException) {
|
||||
false
|
||||
} catch (e: URISyntaxException) {
|
||||
false
|
||||
} catch (e: IllegalArgumentException) {
|
||||
false
|
||||
}
|
||||
|
||||
fun parseImageOrVideo(fullUrl: String): BaseMediaContent {
|
||||
|
||||
Reference in New Issue
Block a user