From d5e6e939e32283cfbf9966a3980f3f330e1a683a Mon Sep 17 00:00:00 2001 From: Jan Paepke Date: Fri, 6 Sep 2024 15:48:27 +0200 Subject: [PATCH] add endpoint normalization --- src/communication/NetworkClient.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/communication/NetworkClient.ts b/src/communication/NetworkClient.ts index a88165c2..1ab265ae 100644 --- a/src/communication/NetworkClient.ts +++ b/src/communication/NetworkClient.ts @@ -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);