From 2e309b2a0b3780937f9c56a02f81d0153504eb7d Mon Sep 17 00:00:00 2001 From: Hari R <37411837+haricane8133@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:21:53 +0530 Subject: [PATCH] Fixes #7, another dormant bug (#9) * Fixes #7, another dormant bug * Review comment - Combine Regexes --- ui/src/components/NavLink.jsx | 3 ++- ui/src/plugins/fetch.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ui/src/components/NavLink.jsx b/ui/src/components/NavLink.jsx index 3fd7b4623..5763dc115 100644 --- a/ui/src/components/NavLink.jsx +++ b/ui/src/components/NavLink.jsx @@ -26,7 +26,8 @@ export default React.forwardRef((props, ref) => { ); } else { - const href = absolutePath ? url.toString() : cleanDuplicateSlash(getBasename() + url.toString()); + // Note: + '/' + is required here + const href = absolutePath ? url.toString() : cleanDuplicateSlash(getBasename() + '/' + url.toString()); return ( {rest.children} diff --git a/ui/src/plugins/fetch.js b/ui/src/plugins/fetch.js index 4467339ce..16761e771 100644 --- a/ui/src/plugins/fetch.js +++ b/ui/src/plugins/fetch.js @@ -41,6 +41,11 @@ export function fetchWithContext( }); } +/** + * @param {string} path + * @returns path with '/' not duplicated, except at :// + * + */ export function cleanDuplicateSlash(path) { - return path.replace(/([^:]\/)\/+/g, "$1"); + return path.replace(/(:\/\/)\/*|(\/)+/g, "$1$2"); }