optionally include user data

This commit is contained in:
Serhii 2024-12-31 12:21:45 +02:00
parent ef0054b057
commit 8678ec4660

View file

@ -219,21 +219,25 @@ abstract class NodeCreateOrEditViewModelBase with Store {
throw Exception('Unexpected scan QR code value: value is empty'); throw Exception('Unexpected scan QR code value: value is empty');
} }
if (!code.contains('://')) { if (!code.contains('://')) code = 'tcp://$code';
code = 'tcp://$code';
}
final uri = Uri.tryParse(code); final uri = Uri.tryParse(code);
if (uri == null || uri.host.isEmpty) { if (uri == null || uri.host.isEmpty) {
throw Exception('Invalid QR code: Unable to parse or missing host.'); throw Exception('Invalid QR code: Unable to parse or missing host.');
} }
final userInfo = uri.userInfo;
final ipAddress = uri.host; final ipAddress = uri.host;
final port = uri.hasPort ? uri.port.toString() : ''; final port = uri.hasPort ? uri.port.toString() : '';
final path = uri.path; final path = uri.path;
final queryParams = uri.queryParameters; // Currently not used
final rpcUser = userInfo.split(':').first;
final rpcPassword = userInfo.split(':').length > 1 ? userInfo.split(':')[1] : '';
setAddress(ipAddress); setAddress(ipAddress);
setPath(path); setPath(path);
setPassword(rpcPassword);
setLogin(rpcUser);
setPort(port); setPort(port);
} on Exception catch (e) { } on Exception catch (e) {
connectionState = FailureState(e.toString()); connectionState = FailureState(e.toString());