mentions: fix bech32 mentions at end

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-08-07 07:09:11 -07:00
parent b7513f28fa
commit 61f5d1009e
3 changed files with 38 additions and 9 deletions

View File

@@ -70,14 +70,12 @@ func parse_post_bech32_mention(_ p: Parser) -> ReferencedId? {
return nil
}
var end = p.pos
if consume_until(p, match: { c in !is_bech32_char(c) }) {
end = p.pos
} else {
p.pos = start
guard consume_until(p, match: { c in !is_bech32_char(c) }, end_ok: true) else {
return nil
}
let end = p.pos
let sliced = String(substring(p.str, start: start, end: end))
guard let decoded = try? bech32_decode(sliced) else {
p.pos = start