Skip to content

Commit

Permalink
Fixes #7, another dormant bug (#9)
Browse files Browse the repository at this point in the history
* Fixes #7, another dormant bug

* Review comment - Combine Regexes
  • Loading branch information
haricane8133 authored Jan 9, 2024
1 parent f42a279 commit 2e309b2
Show file tree
Hide file tree
Showing 2 changed files with 8 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
7 changes: 6 additions & 1 deletion ui/src/plugins/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

0 comments on commit 2e309b2

Please sign in to comment.