From 4f23fef337cbc9f157ba9f684709c754afedb5ef 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 f5830d8e..67895bb1 100644 --- a/src/communication/NetworkClient.ts +++ b/src/communication/NetworkClient.ts @@ -127,6 +127,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);