aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-07-19 16:31:37 +0530
committerGitHub <noreply@github.com>2021-07-19 16:31:37 +0530
commit392ad847bf522e2d3246e4fb62d4015b8c4b1d92 (patch)
tree479dddffd13e82a807f8769bab98e59c70ddeacf /app/src
parent921e9f96b9bec5e2bf8633947792d6991956507f (diff)
Cleanup and fix CI tests (#1464)
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt12
1 files changed, 4 insertions, 8 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt b/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt
index a420fe5d..ecf5f1ca 100644
--- a/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt
@@ -13,10 +13,10 @@ class UriTotpFinder @Inject constructor() : TotpFinder {
override fun findSecret(content: String): String? {
content.split("\n".toRegex()).forEach { line ->
- if (line.startsWith(TOTP_FIELDS[0])) {
+ if (line.startsWith(TotpFinder.TOTP_FIELDS[0])) {
return Uri.parse(line).getQueryParameter("secret")
}
- if (line.startsWith(TOTP_FIELDS[1], ignoreCase = true)) {
+ if (line.startsWith(TotpFinder.TOTP_FIELDS[1], ignoreCase = true)) {
return line.split(": *".toRegex(), 2).toTypedArray()[1]
}
}
@@ -42,15 +42,11 @@ class UriTotpFinder @Inject constructor() : TotpFinder {
private fun getQueryParameter(content: String, parameterName: String): String? {
content.split("\n".toRegex()).forEach { line ->
val uri = Uri.parse(line)
- if (line.startsWith(TOTP_FIELDS[0]) && uri.getQueryParameter(parameterName) != null) {
+ if (line.startsWith(TotpFinder.TOTP_FIELDS[0]) && uri.getQueryParameter(parameterName) != null
+ ) {
return uri.getQueryParameter(parameterName)
}
}
return null
}
-
- companion object {
-
- val TOTP_FIELDS = arrayOf("otpauth://totp", "totp:")
- }
}