Skip to content
Snippets Groups Projects
Commit fbad276e authored by vjrj's avatar vjrj
Browse files

june:key?comment support

parent d49a87e9
No related branches found
No related tags found
No related merge requests found
......@@ -175,6 +175,8 @@ PaymentState? parseScannedUri(String qr) {
r'(duniter\:key|june\:\/)/(\w+(:\w{3})?)\?(comment=([^&]+))&amount=([\d.,]+)');
final RegExp regexKeyAmountComment = RegExp(
r'(duniter\:key|june\:\/)/(\w+(:\w{3})?)\?(amount=([\d.,]+))&comment=([^&]+)');
final RegExp regexKeyComment =
RegExp(r'(duniter\:key|june\:\/)/(\w+(:\w{3})?)\?comment=([^&]+)');
final RegExp regexKeyAmount =
RegExp(r'(duniter\:key|june\:\/)/(\w+(:\w{3})?)\?amount=([\d.,]+)');
final RegExp regexKey = RegExp(r'(duniter\:key|june\:\/)/(\w+(:\w{3})?)');
......@@ -185,6 +187,8 @@ PaymentState? parseScannedUri(String qr) {
final RegExpMatch? matchKeyAmountComment =
regexKeyAmountComment.firstMatch(qr);
final RegExpMatch? matchKeyComment = regexKeyComment.firstMatch(qr);
if (matchKeyCommentAmount != null && matchKeyAmountComment == null) {
final String publicKey = matchKeyCommentAmount.group(2)!;
final String? comment = matchKeyCommentAmount.group(5);
......@@ -209,6 +213,13 @@ PaymentState? parseScannedUri(String qr) {
comment: comment ?? '');
}
if (matchKeyComment != null) {
final String publicKey = matchKeyComment.group(2)!;
final String? comment = matchKeyComment.group(4);
return PaymentState(
contact: Contact(pubKey: publicKey), comment: comment ?? '');
}
final RegExpMatch? matchKeyAmount = regexKeyAmount.firstMatch(qr);
if (matchKeyAmount != null) {
......
......@@ -121,6 +121,22 @@ void main() {
expect(payM.amount, equals(10));
expect(payM.contact!.pubKey,
equals('DsEx1pS33vzYZg4MroyBV9hCw98j1gtHEhwiZ5tK7ech'));
const String uriN =
'june://DsEx1pS33vzYZg4MroyBV9hCw98j1gtHEhwiZ5tK7ech?comment=This Is my comment';
final PaymentState? payN = parseScannedUri(uriN);
expect(payN!.amount == null, equals(true));
expect(payN.comment, equals('This Is my comment'));
expect(payN.contact!.pubKey,
equals('DsEx1pS33vzYZg4MroyBV9hCw98j1gtHEhwiZ5tK7ech'));
const String uriO =
'june://DsEx1pS33vzYZg4MroyBV9hCw98j1gtHEhwiZ5tK7ech:XXX?comment=This Is my comment';
final PaymentState? payO = parseScannedUri(uriO);
expect(payO!.amount == null, equals(true));
expect(payO.comment, equals('This Is my comment'));
expect(payO.contact!.pubKey,
equals('DsEx1pS33vzYZg4MroyBV9hCw98j1gtHEhwiZ5tK7ech:XXX'));
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment