Skip to content

Commit

Permalink
Ignore malformed URL
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Jul 25, 2023
1 parent cf58d00 commit 79680f4
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import space.celestia.mobilecelestia.common.NavigationFragment
import space.celestia.mobilecelestia.compose.LinkPreview
import space.celestia.mobilecelestia.info.model.*
import space.celestia.mobilecelestia.utils.getOverviewForSelection
import java.net.MalformedURLException
import java.net.URL
import javax.inject.Inject

Expand Down Expand Up @@ -119,9 +120,13 @@ class InfoFragment : NavigationFragment.SubFragment() {
id = R.dimen.common_page_medium_gap_vertical
)))
}
val url = selection.webInfoURL
val urlString = selection.webInfoURL
var url: URL? = null
try {
url = URL(urlString)
} catch (ignored: MalformedURLException) {}
if (hasWebInfo && url != null) {
LinkPreview(url = URL(url), modifier = rowModifier.padding(bottom = dimensionResource(id = R.dimen.common_page_medium_gap_vertical)), loadResult = { loadResult ->
LinkPreview(url = url, modifier = rowModifier.padding(bottom = dimensionResource(id = R.dimen.common_page_medium_gap_vertical)), loadResult = { loadResult ->
isWebInfoLoaded = loadResult
}, onClick = { finalURL ->
listener?.onInfoLinkMetaDataClicked(finalURL)
Expand Down

0 comments on commit 79680f4

Please sign in to comment.