Skip to content

Commit

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

* Review comment - Combine Regexes
  • Loading branch information
haricane8133 authored and matiasbur committed May 9, 2024
1 parent 5a8c8d1 commit d5a269b
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 d5a269b

Please sign in to comment.