fix: Do not use Domain match detection for Android and iOS apps URIs

This commit is contained in:
Artem Chepurnoy 2024-12-22 12:04:22 +02:00
parent ed90a65b14
commit 6768a31800
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E

View File

@ -23,6 +23,7 @@ class CipherUrlCheckImpl(
) : CipherUrlCheck {
companion object {
private const val PROTOCOL_ANDROID_APP = "androidapp://"
private const val PROTOCOL_IOS_APP = "iosapp://"
}
constructor(directDI: DirectDI) : this(
@ -37,9 +38,14 @@ class CipherUrlCheckImpl(
): IO<Boolean> {
return when (uri.match ?: defaultMatchDetection) {
DSecret.Uri.MatchType.Domain -> {
when {
uri.uri.startsWith(PROTOCOL_ANDROID_APP) -> ::checkUrlMatchByHost
else -> ::checkUrlMatchByDomain
val shouldUseHostMatchInstead = uri.uri.startsWith(PROTOCOL_ANDROID_APP) ||
url.startsWith(PROTOCOL_ANDROID_APP) ||
uri.uri.startsWith(PROTOCOL_IOS_APP) ||
url.startsWith(PROTOCOL_IOS_APP)
if (shouldUseHostMatchInstead) {
::checkUrlMatchByHost
} else {
::checkUrlMatchByDomain
}
}