Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made parsing address from qr code more accurate #1548

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import com.vultisig.wallet.ui.components.UiSpacer
import com.vultisig.wallet.ui.models.ScanQrViewModel
import com.vultisig.wallet.ui.theme.Theme
import com.vultisig.wallet.ui.utils.addWhiteBorder
import com.vultisig.wallet.ui.utils.getAddressFromQrCode
import com.vultisig.wallet.ui.utils.uriToBitmap
import kotlinx.coroutines.launch
import timber.log.Timber
Expand Down Expand Up @@ -97,7 +98,7 @@ internal fun ScanQrScreen(
if (viewModel.getFlowType(qr) == JOIN_SEND_ON_ADDRESS_FLOW) {
navController.previousBackStackEntry
?.savedStateHandle
?.set(ARG_QR_CODE, qr)
?.set(ARG_QR_CODE, qr.getAddressFromQrCode())
}
navController.popBackStack()
}
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/java/com/vultisig/wallet/ui/utils/StringX.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.vultisig.wallet.ui.utils

internal fun String.getAddressFromQrCode(): String {
val removedPrefix = if (contains(":")) {
substringAfter(":")
val removedSlashPrefix = if (contains("/")) {
substringAfterLast("/")
} else {
this
}
val removedSuffix = if (contains("?")) {
val removedPrefix = if (removedSlashPrefix.contains(":")) {
removedSlashPrefix.substringAfter(":")
} else {
removedSlashPrefix
}
val removedSuffix = if (removedPrefix.contains("?")) {
removedPrefix.substringBefore("?")
} else {
removedPrefix
Expand Down
Loading