mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-04 06:32:59 +00:00
store: dispatch name codes on the length digits
This commit is contained in:
1 parent
3ee2966bdb
commit
098de69b5b
1 file changed
+5
-3
@@ -157,9 +157,11 @@ nameCodePrefix = "SN"
|
||||
parseNameCode :: Text -> Maybe NameCode
|
||||
parseNameCode t = do
|
||||
body <- T.stripPrefix nameCodePrefix $ T.toUpper $ T.filter isAlphaNum t
|
||||
if T.length body == nameOwnerCodeLength
|
||||
then NCOwner <$> parseOwnerBody body
|
||||
else NCPrepaid <$> parsePrepaidBody body
|
||||
case T.length body of
|
||||
n
|
||||
| n == nameOwnerCodeLength -> NCOwner <$> parseOwnerBody body
|
||||
| n - codeLength `elem` [1 .. length (show maxPrepaidNameLength)] -> NCPrepaid <$> parsePrepaidBody body
|
||||
| otherwise -> Nothing
|
||||
|
||||
-- | The code as it is shown and printed.
|
||||
formatNameCode :: NameCode -> Text
|
||||
|
||||
Reference in new issue
Block a user