Skip to content

Commit fd4376d

Browse files
committed
api: Assert in Auth that realmUrl doesn't have query or fragment
1 parent cb25643 commit fd4376d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

lib/api/core.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import 'package:flutter/foundation.dart';
44
import 'package:http/http.dart' as http;
55

66
class Auth {
7-
const Auth({required this.realmUrl, required this.email, required this.apiKey});
7+
Auth({required this.realmUrl, required this.email, required this.apiKey})
8+
: assert(Uri.parse(realmUrl).query.isEmpty && Uri.parse(realmUrl).fragment.isEmpty);
89

910
final String realmUrl;
1011
final String email;

lib/model/store.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class PerAccountStore extends ChangeNotifier {
204204

205205
@immutable
206206
class Account extends Auth {
207-
const Account({
207+
Account({
208208
required super.realmUrl,
209209
required super.email,
210210
required super.apiKey,
@@ -243,7 +243,7 @@ class LiveGlobalStore extends GlobalStore {
243243
///
244244
/// See "Server credentials" in the project README for how to fill in the
245245
/// `credential_fixture.dart` file this requires.
246-
const Account _fixtureAccount = Account(
246+
final Account _fixtureAccount = Account(
247247
realmUrl: credentials.realmUrl,
248248
email: credentials.email,
249249
apiKey: credentials.apiKey,

test/example_data.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const String realmUrl = 'https://chat.example/';
77
const String recentZulipVersion = '6.1';
88
const int recentZulipFeatureLevel = 164;
99

10-
const Account selfAccount = Account(
10+
final Account selfAccount = Account(
1111
realmUrl: realmUrl,
1212
email: 'self@example',
1313
apiKey: 'asdfqwer',
@@ -17,7 +17,7 @@ const Account selfAccount = Account(
1717
zulipMergeBase: recentZulipVersion,
1818
);
1919

20-
const Account otherAccount = Account(
20+
final Account otherAccount = Account(
2121
realmUrl: realmUrl,
2222
email: 'other@example',
2323
apiKey: 'sdfgwert',

0 commit comments

Comments
 (0)