Skip to content

Commit

Permalink
Handle typo in powersync_url env variable (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
HeinrichvonStein authored Oct 29, 2024
1 parent 0898a58 commit 79d4211
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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

0 comments on commit 79d4211

Please sign in to comment.