Skip to content

Commit 2e309b2

Browse files
authored
Fixes #7, another dormant bug (#9)
* Fixes #7, another dormant bug * Review comment - Combine Regexes
1 parent f42a279 commit 2e309b2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

ui/src/components/NavLink.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export default React.forwardRef((props, ref) => {
2626
</Link>
2727
);
2828
} else {
29-
const href = absolutePath ? url.toString() : cleanDuplicateSlash(getBasename() + url.toString());
29+
// Note: + '/' + is required here
30+
const href = absolutePath ? url.toString() : cleanDuplicateSlash(getBasename() + '/' + url.toString());
3031
return (
3132
<Link ref={ref} target="_blank" href={href}>
3233
{rest.children}

ui/src/plugins/fetch.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export function fetchWithContext(
4141
});
4242
}
4343

44+
/**
45+
* @param {string} path
46+
* @returns path with '/' not duplicated, except at ://
47+
*
48+
*/
4449
export function cleanDuplicateSlash(path) {
45-
return path.replace(/([^:]\/)\/+/g, "$1");
50+
return path.replace(/(:\/\/)\/*|(\/)+/g, "$1$2");
4651
}

0 commit comments

Comments
 (0)