Skip to content

Commit ce37341

Browse files
authored
Merge pull request #366 from janpaepke/apiurl-improvement
Add normalization to the apiEndpoint option.
2 parents cfc1ef8 + 3785aa5 commit ce37341

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/communication/NetworkClient.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ export default class NetworkClient {
137137
// Create retrying fetch function.
138138
const fetchWithRetries = retryingFetch(fetch);
139139

140+
// 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.
141+
if (!apiEndpoint.endsWith('/')) {
142+
apiEndpoint += '/';
143+
}
144+
140145
// Create the request function.
141146
this.request = (pathname, options) => {
142147
const url = new URL(pathname, apiEndpoint);

0 commit comments

Comments
 (0)