fix: domain comparison

This commit is contained in:
Rongjian Zhang 2019-09-26 22:40:53 +08:00
parent f2e312079b
commit b958ddf0cf
2 changed files with 11 additions and 3 deletions

View File

@ -11,8 +11,16 @@ class AccountModel {
String login;
String avatarUrl;
equals(AccountModel a) =>
a.platform == platform && a.domain == domain && a.login == login;
equals(AccountModel a) {
final uri = Uri.parse(domain);
final uriA = Uri.parse(a.domain);
// Treat domains as the same if they have the same hosts and ports
return a.platform == platform &&
a.login == login &&
uri.host == uriA.host &&
uri.port == uriA.port;
}
AccountModel({
@required this.platform,

View File

@ -109,7 +109,7 @@ class SettingsModel with ChangeNotifier {
await _setAccounts(AccountModel(
platform: PlatformType.github,
domain: 'github.com',
domain: 'https://github.com',
token: token,
login: queryData['viewer']['login'] as String,
avatarUrl: queryData['viewer']['avatarUrl'] as String,