Compare commits
1 commit
a9479d9106
...
6986ab5a1c
Author | SHA1 | Date | |
---|---|---|---|
6986ab5a1c |
1 changed files with 3 additions and 3 deletions
|
@ -7,9 +7,9 @@ data class ActivationCode(
|
||||||
val confirmationCodeRequired: Boolean = false,
|
val confirmationCodeRequired: Boolean = false,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
fun fromString(token: String): ActivationCode {
|
fun fromString(input: String): ActivationCode {
|
||||||
val input = if (token.startsWith("LPA:", true)) token.drop(4) else token
|
check(input.startsWith("LPA:", ignoreCase = true)) { "Invalid activation code format" }
|
||||||
val components = input.split('$').map { it.trim().ifEmpty { null } }
|
val components = input.drop(4).split('$').map { it.trim().ifEmpty { null } }
|
||||||
check(components.size >= 2) { "Invalid activation code format" }
|
check(components.size >= 2) { "Invalid activation code format" }
|
||||||
check(components[0] == "1") { "Invalid activation code version" }
|
check(components[0] == "1") { "Invalid activation code version" }
|
||||||
return ActivationCode(
|
return ActivationCode(
|
||||||
|
|
Loading…
Add table
Reference in a new issue