Skip to content

Commit f2440d7

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

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

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

205-
let url = new URL(uri);
205+
// We use .toString() here because some versions of React Native contain a bug where the URL constructor
206+
// incorrectly treats a URL instance as a plain string.
207+
// This results in an attempt to call .endsWith() on it, leading to an error.
208+
let url = new URL(uri.toString());
206209
if (!/^wss?:/.test(uri.protocol)) {
207210
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
208211
}

0 commit comments

Comments
 (0)