@@ -2,10 +2,9 @@ import React from 'react'
22import PropTypes from 'prop-types'
33import classNames from 'classnames'
44import { CBreadcrumb , CBreadcrumbItem } from '../index'
5- import { Link , useLocation } from 'react-router-dom' ;
5+ import { Link , useLocation , matchPath } from 'react-router-dom' ;
66
77//component - CoreUI / CBreadcrumbRouter
8-
98const getPaths = pathname => {
109 const paths = [ '/' ]
1110 if ( pathname === '/' ) return paths ;
@@ -33,25 +32,28 @@ const CBreadcrumbRouter = props => {
3332
3433 const {
3534 className,
36- //
3735 innerRef,
3836 routes,
3937 ...attributes
40- } = props ;
38+ } = props
4139
4240 let items = null
4341 if ( routes ) {
4442 const currPath = useLocation ( ) . pathname
4543 const paths = getPaths ( currPath )
46- const currRoutes = routes . filter ( route => paths . includes ( route . path ) )
44+ const currRoutes = paths . map ( path => {
45+ return routes . find ( route => matchPath ( path , {
46+ path : route . path ,
47+ exact : route . exact
48+ } ) )
49+ } ) . filter ( route => route )
4750 items = currRoutes . map ( route => {
4851 return CBreadcrumbRouteItem ( route , currPath )
4952 } )
5053 }
5154
5255
5356 //render
54-
5557 const classes = classNames ( className )
5658
5759 return (
@@ -67,7 +69,6 @@ const CBreadcrumbRouter = props => {
6769
6870CBreadcrumbRouter . propTypes = {
6971 className : PropTypes . string ,
70- //
7172 innerRef : PropTypes . oneOfType ( [ PropTypes . object , PropTypes . func , PropTypes . string ] ) ,
7273 routes : PropTypes . array
7374}
0 commit comments