fix(autofill): Ignore port during Host match if not specified in the source #629
This commit is contained in:
parent
89e77ec65d
commit
e29c1d7f3c
|
@ -7,6 +7,7 @@ import com.artemchep.keyguard.common.io.ioEffect
|
||||||
import com.artemchep.keyguard.common.model.DSecret
|
import com.artemchep.keyguard.common.model.DSecret
|
||||||
import com.artemchep.keyguard.common.service.tld.TldService
|
import com.artemchep.keyguard.common.service.tld.TldService
|
||||||
import com.artemchep.keyguard.common.usecase.CipherUrlCheck
|
import com.artemchep.keyguard.common.usecase.CipherUrlCheck
|
||||||
|
import io.ktor.http.DEFAULT_PORT
|
||||||
import io.ktor.http.Url
|
import io.ktor.http.Url
|
||||||
import io.ktor.http.hostWithPort
|
import io.ktor.http.hostWithPort
|
||||||
import org.kodein.di.DirectDI
|
import org.kodein.di.DirectDI
|
||||||
|
@ -66,9 +67,15 @@ class CipherUrlCheckImpl(
|
||||||
a: String,
|
a: String,
|
||||||
b: String,
|
b: String,
|
||||||
): IO<Boolean> = ioEffect {
|
): IO<Boolean> = ioEffect {
|
||||||
val aHost = urlOf(a).hostWithPort
|
val aUrl = urlOf(a)
|
||||||
val bHost = urlOf(b).hostWithPort
|
val bUrl = urlOf(b)
|
||||||
aHost == bHost
|
// If the url doesn't have a port specified, then
|
||||||
|
// match it with any port.
|
||||||
|
if (aUrl.specifiedPort == DEFAULT_PORT) {
|
||||||
|
return@ioEffect aUrl.host == bUrl.host
|
||||||
|
}
|
||||||
|
|
||||||
|
aUrl.hostWithPort == bUrl.hostWithPort
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkUrlMatchByStartsWith(
|
private fun checkUrlMatchByStartsWith(
|
||||||
|
|
Loading…
Reference in New Issue