Skip to content

Commit

Permalink
Merge pull request #49 from JumboCode/sburchfield33/tab_buttons_fix
Browse files Browse the repository at this point in the history
Sburchfield33/tab buttons fix
  • Loading branch information
sburchfield33 committed Nov 15, 2023
2 parents 5ffe4ca + 1c6f54e commit 7d0448b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/components/TabButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ const TabButtons = ({ queries }: TabButtonsProps) => {
const isTabSelected =
segment === query || (segment === null && index === 0);

/* If segment is null, add to the end of pathName
* Otherwise replace end of pathName with new query */
const href =
segment === null
? pathName + "/" + query
: pathName.split("/").slice(0, -1).join("/") + "/" + query;

const base = pathName.match(
new RegExp(`.*?(?=${queries.map((q) => "/" + q).join("|")}|$)`)
) as RegExpExecArray;
const href = `${base[0]}/${query}`;

return (
<div key={query}>
<Link
Expand Down

0 comments on commit 7d0448b

Please sign in to comment.