Skip to content

Commit

Permalink
[SW-1615] Ignore site id when setting breadcrumbs (#1200)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylankelly committed Jun 2, 2022
1 parent 4f2c467 commit 6b188d4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/ripple-nuxt-tide/lib/core/breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Private helpers
const siteMatch = /\/site-(\d+)/
function getActivePath (branch, path) {
for (let i = 0; i < branch.length; i++) {
const item = branch[i]
if (item.url === path) {
// ignore site id prefix when matching active path
if (item.url.replace(siteMatch, '') === path.replace(siteMatch, '')) {
return [{
text: item.text,
url: item.url
Expand Down
26 changes: 26 additions & 0 deletions packages/ripple-nuxt-tide/test/unit/breadcrumbs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,30 @@ describe('breadcrumbs', () => {
const result = breadcrumbs('/null-menu', 'Null Menu', null)
expect(result).toEqual(expectedResult)
})

test('should ignore site id when evaluating activepath', async () => {
const expectedResult = [
{
text: 'Home',
url: '/'
},
{
text: 'Alpha 1',
url: '/alpha-1'
},
{
text: 'Alpha 2',
url: '/alpha-2'
},
{
text: 'Alpha 3',
url: '/site-123/alpha-3'
}
]
const testMenu = JSON.parse(JSON.stringify(nestedMenu))
testMenu[0].children[0].children[0].url = '/site-123/alpha-3'

const result = breadcrumbs('/alpha-3', 'Alpha 3', testMenu)
expect(result).toEqual(expectedResult)
})
})

0 comments on commit 6b188d4

Please sign in to comment.