diff --git a/core/src/main/kotlin/dev/hotwire/core/turbo/config/PathConfigurationData.kt b/core/src/main/kotlin/dev/hotwire/core/turbo/config/PathConfigurationData.kt index f54b551..73c84a9 100644 --- a/core/src/main/kotlin/dev/hotwire/core/turbo/config/PathConfigurationData.kt +++ b/core/src/main/kotlin/dev/hotwire/core/turbo/config/PathConfigurationData.kt @@ -1,6 +1,7 @@ package dev.hotwire.core.turbo.config import com.google.gson.annotations.SerializedName +import java.net.MalformedURLException import java.net.URL @ConsistentCopyVisibility @@ -36,7 +37,11 @@ data class PathConfigurationData internal constructor( } private fun path(location: String): String { - val url = URL(location) + val url = try { + URL(location) + } catch (e: MalformedURLException) { + return "" + } return if (url.query == null) { url.path diff --git a/core/src/test/kotlin/dev/hotwire/core/turbo/config/PathConfigurationTest.kt b/core/src/test/kotlin/dev/hotwire/core/turbo/config/PathConfigurationTest.kt index 56549ad..9bebba6 100644 --- a/core/src/test/kotlin/dev/hotwire/core/turbo/config/PathConfigurationTest.kt +++ b/core/src/test/kotlin/dev/hotwire/core/turbo/config/PathConfigurationTest.kt @@ -201,6 +201,14 @@ class PathConfigurationTest : BaseRepositoryTest() { assertThat(pathConfiguration.properties("$url/new").pullToRefreshEnabled).isFalse } + @Test + fun unknownSchemeLocationDoesNotThrow() { + assertThat(pathConfiguration.properties("mailto:test@example.com")).isNotNull + assertThat(pathConfiguration.properties("tel:+15551234567")).isNotNull + assertThat(pathConfiguration.properties("sms:+15551234567")).isNotNull + assertThat(pathConfiguration.properties("custom-app://feature")).isNotNull + } + @Test fun customProperties() { assertThat((pathConfiguration.properties("$url/custom/tabs").getTabs()?.size)).isEqualTo(1)