Skip to content

Commit

Permalink
Merge pull request #366 from janpaepke/apiurl-improvement
Browse files Browse the repository at this point in the history
Add normalization to the apiEndpoint option.
  • Loading branch information
Pimm authored Sep 10, 2024
2 parents cfc1ef8 + 3785aa5 commit ce37341
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 in the full URL. Without a trailing slash it would be ignored.
if (!apiEndpoint.endsWith('/')) {
apiEndpoint += '/';
}

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

0 comments on commit ce37341

Please sign in to comment.