mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-25 23:14:18 +03:00
Simplify QR URI validation.
This commit is contained in:
parent
f129d415a4
commit
859ad926c4
@ -70,7 +70,8 @@ class _QrScannerViewState extends State<QrScannerView> {
|
||||
setState(() {
|
||||
if (qrCodeData.isNotEmpty) {
|
||||
try {
|
||||
_validateQrCodeUri(Uri.parse(qrCodeData)); // throws ArgumentError if validation fails
|
||||
CredentialData.fromUri(Uri.parse(
|
||||
qrCodeData)); // throws ArgumentError if validation fails
|
||||
_scannedString = qrCodeData;
|
||||
_status = ScanStatus.success;
|
||||
|
||||
@ -92,18 +93,6 @@ class _QrScannerViewState extends State<QrScannerView> {
|
||||
});
|
||||
}
|
||||
|
||||
void _validateQrCodeUri(Uri qrCodeUri) {
|
||||
try {
|
||||
CredentialData.fromUri(qrCodeUri);
|
||||
} on ArgumentError catch (_) {
|
||||
try {
|
||||
CredentialData.fromMigration(qrCodeUri);
|
||||
} on ArgumentError catch (_) {
|
||||
throw ArgumentError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
Loading…
Reference in New Issue
Block a user