From 38fe06b994efb56bf18182d07252dc8b6e1fc54d Mon Sep 17 00:00:00 2001 From: Josefina Mancilla <32556167+jnm2377@users.noreply.github.com> Date: Tue, 24 Sep 2019 08:51:02 -0500 Subject: [PATCH] fix(navigation): fix page tabs replace bug (#437) * fix(navigation): fix page tabs replace bug * fix: update regex * fix: clean up code * fix: rename var --- .../gatsby-theme-carbon/src/components/PageTabs/PageTabs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/gatsby-theme-carbon/src/components/PageTabs/PageTabs.js b/packages/gatsby-theme-carbon/src/components/PageTabs/PageTabs.js index ccb614e8b..197388cca 100644 --- a/packages/gatsby-theme-carbon/src/components/PageTabs/PageTabs.js +++ b/packages/gatsby-theme-carbon/src/components/PageTabs/PageTabs.js @@ -28,7 +28,8 @@ export default class PageTabs extends React.Component { const pageTabs = tabs.map(tab => { const slugifiedTab = slugify(tab, { lower: true }); const selected = slugifiedTab === currentTab; - const href = slug.replace(currentTab, slugifiedTab); + const currentTabRegex = new RegExp(`${currentTab}(?!-)`); + const href = slug.replace(currentTabRegex, slugifiedTab); return (