Skip to content

Commit 4b0ab04

Browse files
committed
fix(ts-sdk): use toString() to allow older react native versions to work
1 parent 83f52ca commit 4b0ab04

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sdks/typescript/packages/sdk/src/db_connection_impl.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ export class DbConnectionImpl<
202202
}: DbConnectionConfig) {
203203
stdbLogger('info', 'Connecting to SpacetimeDB WS...');
204204

205-
let url = new URL(uri);
205+
// Use .toString() due to some React Native versions have a bug where the `URL` constructor treat
206+
// tries to call `.endsWith()` on an URI object, therefore causing an error.
207+
let url = new URL(uri.toString());
206208
if (!/^wss?:/.test(uri.protocol)) {
207209
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
208210
}

0 commit comments

Comments
 (0)