Skip to content

Commit

Permalink
fix: only add a url if one exists for a parent
Browse files Browse the repository at this point in the history
  • Loading branch information
zstix committed May 19, 2020
1 parent 04dbe56 commit 610b999
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils/create-breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ const createBreadcrumbs = (url, links, result = []) => {
// if the crumbs are different, we found a valid match below this link
if (crumbs !== result) {
// get the details for this link without the children
const { url, displayName } = link;
let parentLink = { displayName: link.displayName };
if (link.url) parentLink.url = link.url;

// return the current crumbs, this link, and the crumbs found below
return [...acc, { url, displayName }, ...crumbs];
return [...acc, parentLink, ...crumbs];
} else {
// otherwise, this is an invalid branch, just return the result so far
return acc;
Expand Down

0 comments on commit 610b999

Please sign in to comment.