From 392ad847bf522e2d3246e4fb62d4015b8c4b1d92 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 19 Jul 2021 16:31:37 +0530 Subject: Cleanup and fix CI tests (#1464) --- .../main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'app/src') 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:") - } } -- cgit v1.2.3