lnlink

iOS app for connecting to lightning nodes
git clone git://jb55.com/lnlink
Log | Files | Refs | Submodules | README | LICENSE

commit d214a66f812cc11a8f3229389f948ca45d5e2d1b
parent 68e1aeb1214e7fcd11144d5cfd6f5a8ccf7ab2c0
Author: William Casarin <jb55@jb55.com>
Date:   Thu,  3 Mar 2022 15:59:39 -0800

qr: trim strings

weird that some qr codes are like this...

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mlightninglink/Views/ContentView.swift | 1+
Mlightninglink/Views/SetupView.swift | 3+++
2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lightninglink/Views/ContentView.swift b/lightninglink/Views/ContentView.swift @@ -194,6 +194,7 @@ struct ContentView: View { let index = code.index(code.startIndex, offsetBy: 10) invstr = String(code[index...]) } + invstr = invstr.trimmingCharacters(in: .whitespacesAndNewlines) let m_parsed = parseInvoiceString(invstr) guard let parsed = m_parsed else { return diff --git a/lightninglink/Views/SetupView.swift b/lightninglink/Views/SetupView.swift @@ -162,6 +162,9 @@ func parse_auth_qr(_ qr: String) -> Either<String, LNLink> { auth_qr = qr.replacingOccurrences(of: "lnlink:", with: "lnlink://") } + // some qrcodes are weird like this + auth_qr = auth_qr.trimmingCharacters(in: .whitespacesAndNewlines) + guard let url = URL(string: auth_qr) else { return .left("Invalid url") }