From 2871fb432c9f90f8c76220d6d58e6a95a2c8fc08 Mon Sep 17 00:00:00 2001 From: Amit Ranjan Date: Mon, 30 Sep 2024 22:04:57 +0530 Subject: [PATCH] feat(frontend): added fix for the base url --- frontend/src/utils/URL.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/utils/URL.ts b/frontend/src/utils/URL.ts index b662c9e..b38c124 100644 --- a/frontend/src/utils/URL.ts +++ b/frontend/src/utils/URL.ts @@ -28,7 +28,11 @@ export const getFromQuery = ({ export const buildURL = (baseUrl: string, relativePath: string): string => { try { - const url = new URL(relativePath, baseUrl); + const normalizedBaseUrl = baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`; + const normalizedRelativePath = relativePath.startsWith("/") + ? relativePath.slice(1) + : relativePath; + const url = new URL(normalizedRelativePath, normalizedBaseUrl); return url.toString(); } catch {