improve usernames
This commit is contained in:
parent
98798fa14f
commit
40d57fb245
10 changed files with 106 additions and 0 deletions
|
@ -1 +1,8 @@
|
|||
import 'package:http/http.dart' as http;
|
||||
import 'dart:io';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
import 'package:oauth2/oauth2.dart' as oauth2;
|
||||
|
||||
// Future<http.Client> authorize({required String userid}) {
|
||||
// }
|
||||
|
|
|
@ -19,3 +19,20 @@ Uri urlFromUsername({required String name}) {
|
|||
name = cleanUpUsername(name: name);
|
||||
return Uri.parse("https://${name.substring(name.indexOf("@") + 1)}");
|
||||
}
|
||||
|
||||
String userFromUsername({required String name}) {
|
||||
name = cleanUpUsername(name: name);
|
||||
return name.substring(0, name.indexOf("@"));
|
||||
}
|
||||
|
||||
// A fully qualified and valid username for example (@)hello@world.com
|
||||
// The first @ is ignored
|
||||
class Username {
|
||||
late final String user;
|
||||
late final Uri url;
|
||||
Username(String username) {
|
||||
assert(isValidUsername(name: username));
|
||||
user = userFromUsername(name: username);
|
||||
url = urlFromUsername(name: username);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue