Fix: Url decode the path value
This commit is contained in:
parent
4103b776c4
commit
41c33003ac
2 changed files with 17 additions and 2 deletions
|
@ -67,7 +67,8 @@ class Code {
|
|||
|
||||
static String _getAccount(Uri uri) {
|
||||
try {
|
||||
return uri.path.split(':')[1];
|
||||
final String path = Uri.decodeComponent(uri.path);
|
||||
return path.split(':')[1];
|
||||
} catch (e) {
|
||||
return "";
|
||||
}
|
||||
|
@ -75,7 +76,8 @@ class Code {
|
|||
|
||||
static String _getIssuer(Uri uri) {
|
||||
try {
|
||||
return uri.path.split(':')[0].substring(1);
|
||||
final String path = Uri.decodeComponent(uri.path);
|
||||
return path.split(':')[0].substring(1);
|
||||
} catch (e) {
|
||||
return "";
|
||||
}
|
||||
|
|
13
test/models/code_test.dart
Normal file
13
test/models/code_test.dart
Normal file
|
@ -0,0 +1,13 @@
|
|||
import 'package:ente_auth/models/code.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
test("parseCodeFromRawData", () {
|
||||
final code1 = Code.fromRawData(
|
||||
"otpauth://totp/example%20finance%3Aee%40ff.gg?secret=ASKZNWOU6SVYAMVS",
|
||||
);
|
||||
expect(code1.issuer, "example finance");
|
||||
expect(code1.account, "ee@ff.gg");
|
||||
expect(code1.secret, "ASKZNWOU6SVYAMVS");
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue