Skip to content

Commit

Permalink
Merge pull request #939 from mikepenz/fix/938
Browse files Browse the repository at this point in the history
Protect when opening invalid urls in compose
  • Loading branch information
mikepenz authored Dec 17, 2023
2 parents 834ef6d + 5b33280 commit f33b00e
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.mikepenz.aboutlibraries.entity.Library
import com.mikepenz.aboutlibraries.ui.compose.util.StableLibrary
import com.mikepenz.aboutlibraries.ui.compose.util.StableLibs
import com.mikepenz.aboutlibraries.ui.compose.util.author
import com.mikepenz.aboutlibraries.ui.compose.util.htmlReadyLicenseContent
import com.mikepenz.aboutlibraries.ui.compose.util.stable
import com.mikepenz.aboutlibraries.ui.compose.util.*
import kotlinx.collections.immutable.ImmutableList


Expand Down Expand Up @@ -73,7 +69,13 @@ fun LibrariesContainer(
} else if (!license?.htmlReadyLicenseContent.isNullOrBlank()) {
openDialog.value = library
} else if (!license?.url.isNullOrBlank()) {
license?.url?.also { uriHandler.openUri(it) }
license?.url?.also {
try {
uriHandler.openUri(it)
} catch (t: Throwable) {
println("Failed to open url: ${it}")
}
}
}
},
)
Expand All @@ -96,7 +98,7 @@ fun LicenseDialog(
onDismiss: () -> Unit,
) {
val scrollState = rememberScrollState()

Dialog(
onDismissRequest = onDismiss,
properties = DialogProperties(),
Expand Down Expand Up @@ -173,7 +175,13 @@ fun Libraries(
if (onLibraryClick != null) {
onLibraryClick.invoke(library)
} else if (!license?.url.isNullOrBlank()) {
license?.url?.also { uriHandler.openUri(it) }
license?.url?.also {
try {
uriHandler.openUri(it)
} catch (t: Throwable) {
println("Failed to open url: ${it}")
}
}
}
}
}
Expand Down

0 comments on commit f33b00e

Please sign in to comment.