Display error on invalid invoice slug

This commit is contained in:
Ali
2023-01-18 01:10:34 +04:00
parent 58fa061fa2
commit 7cea72619c
4 changed files with 61 additions and 47 deletions

View File

@@ -272,7 +272,10 @@ public func parseInternalUrl(query: String) -> ParsedInternalUrl? {
return .join(String(component.dropFirst()))
}
} else if pathComponents[0].hasPrefix("$") || pathComponents[0].hasPrefix("%24") {
let component = pathComponents[0].replacingOccurrences(of: "%24", with: "$")
var component = pathComponents[0].replacingOccurrences(of: "%24", with: "$")
if component.hasPrefix("$") {
component = String(component[component.index(after: component.startIndex)...])
}
return .invoice(component)
}
return .peer(.name(peerName), nil)
@@ -745,7 +748,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl)
}
|> map { invoice -> ResolvedUrl? in
guard let invoice = invoice else {
return nil
return .invoice(slug: slug, invoice: nil)
}
return .invoice(slug: slug, invoice: invoice)
}