File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
packages/powersync/lib/src Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -87,11 +87,13 @@ class PowerSyncCredentials {
8787 /// When the token expires. Only use for debugging purposes.
8888 final DateTime ? expiresAt;
8989
90- const PowerSyncCredentials (
90+ PowerSyncCredentials (
9191 {required this .endpoint,
9292 required this .token,
9393 this .userId,
94- this .expiresAt});
94+ this .expiresAt}) {
95+ _validateEndpoint ();
96+ }
9597
9698 factory PowerSyncCredentials .fromJson (Map <String , dynamic > parsed) {
9799 String token = parsed['token' ];
@@ -133,6 +135,15 @@ class PowerSyncCredentials {
133135 Uri endpointUri (String path) {
134136 return Uri .parse (endpoint).resolve (path);
135137 }
138+
139+ _validateEndpoint () {
140+ final parsed = Uri .parse (endpoint);
141+ if ((! parsed.isScheme ('http' ) && ! parsed.isScheme ('https' )) ||
142+ parsed.host.isEmpty) {
143+ throw ArgumentError .value (
144+ endpoint, 'PowerSync endpoint must be a valid URL' );
145+ }
146+ }
136147}
137148
138149/// Credentials used to connect to the PowerSync dev API.
You can’t perform that action at this time.
0 commit comments