Skip to content

Commit

Permalink
Added logic to inject country prefix if it's missing (eu-digital-gree…
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandrsarapulovgl authored Jul 19, 2021
1 parent 864de48 commit eb92318
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ class DefaultPrefixValidationService(private val prefix: String = "HC1:") : Pref
input.startsWith(prefix) -> input.drop(prefix.length).also { verificationResult.contextPrefix = prefix }
else -> input.also { verificationResult.contextPrefix = null }
}

override fun encode(input: String): String = when {
input.startsWith(prefix) -> input
else -> "$prefix$input"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ import dgca.verifier.app.decoder.model.VerificationResult
interface PrefixValidationService {

fun decode(input: String, verificationResult: VerificationResult): String

fun encode(input: String): String
}

0 comments on commit eb92318

Please sign in to comment.