[Partner request] Remove https and trailing slash in an https origin
For example, "https://something/" should be just "something". Bug: 286103811 Fix: 286103811 Test: local verification (see bug for screenshots) Change-Id: Ib6b3b9e99163235f7ae73bc7ebd66571f254ea86
This commit is contained in:
@@ -66,8 +66,9 @@ class CredentialManagerRepo(
|
||||
)
|
||||
|
||||
val originName: String? = when (requestInfo?.type) {
|
||||
RequestInfo.TYPE_CREATE -> requestInfo.createCredentialRequest?.origin
|
||||
RequestInfo.TYPE_GET -> requestInfo.getCredentialRequest?.origin
|
||||
RequestInfo.TYPE_CREATE -> processHttpsOrigin(
|
||||
requestInfo.createCredentialRequest?.origin)
|
||||
RequestInfo.TYPE_GET -> processHttpsOrigin(requestInfo.getCredentialRequest?.origin)
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -247,6 +248,9 @@ class CredentialManagerRepo(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val HTTPS = "https://"
|
||||
private const val FORWARD_SLASH = "/"
|
||||
|
||||
fun sendCancellationCode(
|
||||
cancelCode: Int,
|
||||
requestToken: IBinder?,
|
||||
@@ -266,5 +270,17 @@ class CredentialManagerRepo(
|
||||
CancelUiRequest::class.java
|
||||
)
|
||||
}
|
||||
|
||||
/** Removes "https://", and the trailing slash if present for an https request. */
|
||||
private fun processHttpsOrigin(origin: String?): String? {
|
||||
var processed = origin
|
||||
if (processed?.startsWith(HTTPS) == true) { // Removes "https://"
|
||||
processed = processed.substring(HTTPS.length)
|
||||
if (processed?.endsWith(FORWARD_SLASH) == true) { // Removes the trailing slash
|
||||
processed = processed.substring(0, processed.length - 1)
|
||||
}
|
||||
}
|
||||
return processed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user