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');
}
if (!code.contains('://')) {
code = 'tcp://$code';
}
if (!code.contains('://')) code = 'tcp://$code';
final uri = Uri.tryParse(code);
if (uri == null || uri.host.isEmpty) {
throw Exception('Invalid QR code: Unable to parse or missing host.');
}
final userInfo = uri.userInfo;
final ipAddress = uri.host;
final port = uri.hasPort ? uri.port.toString() : '';
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);
setPath(path);
setPassword(rpcPassword);
setLogin(rpcUser);
setPort(port);
} on Exception catch (e) {
connectionState = FailureState(e.toString());