Skip to content

Commit

Permalink
add endpoint normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
janpaepke committed Sep 10, 2024
1 parent a8d0ed2 commit ecf2b74
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/communication/NetworkClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ export default class NetworkClient {
// Create retrying fetch function.
const fetchWithRetries = retryingFetch(fetch);

// normalize the API endpoint - if you provided a path, you probably meant to include it
if (!apiEndpoint.endsWith('/')) {
apiEndpoint += '/';
}

// Create the request function.
this.request = (pathname, options) => {
const url = new URL(pathname, apiEndpoint);
Expand Down

0 comments on commit ecf2b74

Please sign in to comment.