diff --git a/webui/src/components/Header/Header.tsx b/webui/src/components/Header/Header.tsx index 864b2c398f3e26e3c60512038ddf2f6c3835f659..63146cc9c1d1051db00043b18b66ac09d573e8a5 100644 --- a/webui/src/components/Header/Header.tsx +++ b/webui/src/components/Header/Header.tsx @@ -69,20 +69,11 @@ function Header() { const location = useLocation(); // Prevents error of invalid tab selection in + // Will return a valid tab path or false if path is unkown. function highlightTab() { - switch (location.pathname) { - case '/': - return '/'; - case '/code': - return '/code'; - case '/pulls': - return '/pulls'; - case '/settings': - return '/settings'; - default: - // using false as value for tabs will result in no selected tab - return false; - } + const validTabs = ['/', '/code', '/pulls', '/settings']; + const tab = validTabs.find((tabPath) => tabPath === location.pathname); + return tab === undefined ? false : tab; } return (