Skip to content

Commit

Permalink
Fixes conductor-oss#7, another dormant bug
Browse files Browse the repository at this point in the history
  • Loading branch information
haricane8133 committed Jan 2, 2024
1 parent fec3116 commit 32d7be4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ui/src/components/NavLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export default React.forwardRef((props, ref) => {
</Link>
);
} else {
const href = absolutePath ? url.toString() : cleanDuplicateSlash(getBasename() + url.toString());
// Note: + '/' + is required here
const href = absolutePath ? url.toString() : cleanDuplicateSlash(getBasename() + '/' + url.toString());
return (
<Link ref={ref} target="_blank" href={href}>
{rest.children}
Expand Down
8 changes: 7 additions & 1 deletion ui/src/plugins/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export function fetchWithContext(
});
}

/**
* @param {string} path
* @returns path with '/' not duplicated except at ://
*
* Note: we need the second .replace() because the first one doesn't catch multiple slashes at the start of the string
*/
export function cleanDuplicateSlash(path) {
return path.replace(/([^:]\/)\/+/g, "$1");
return path.replace(/([^:]\/)\/+/g, "$1").replace(/^(\/)+/, '/');
}

0 comments on commit 32d7be4

Please sign in to comment.