Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fuzzy-bears-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@powersync/common': patch
'@powersync/web': patch
---

Handle additional forward slash in the POWERSYNC_URL environment variable
6 changes: 6 additions & 0 deletions packages/common/src/client/sync/stream/AbstractRemote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { version as POWERSYNC_JS_VERSION } from '../../../../package.json';

export type BSONImplementation = typeof BSON;

const POWERSYNC_TRAILING_SLASH_MATCH = /\/+$/;
export type RemoteConnector = {
fetchCredentials: () => Promise<PowerSyncCredentials | null>;
};
Expand Down Expand Up @@ -108,6 +109,11 @@ export abstract class AbstractRemote {
return this.credentials!;
}
this.credentials = await this.connector.fetchCredentials();
if (this.credentials?.endpoint.match(POWERSYNC_TRAILING_SLASH_MATCH)) {
throw new Error(
`A trailing forward slash "/" was found in the fetchCredentials endpoint: "${this.credentials.endpoint}". Remove the trailing forward slash "/" to fix this error.`
);
}
return this.credentials;
}

Expand Down