Skip to content

Commit 7a23c11

Browse files
authored
Merge pull request #26 from coreui/dev-vnext
refactor(Breadcrumb): fix for dynamic url like /path/:id
2 parents 5c57508 + 969bd9c commit 7a23c11

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coreui/react",
3-
"version": "2.0.3",
3+
"version": "2.0.4",
44
"description": "CoreUI React Bootstrap 4 components",
55
"license": "MIT",
66
"author": {
@@ -38,7 +38,7 @@
3838
"@coreui/icons": "0.2.0",
3939
"classnames": "^2.2.6",
4040
"core-js": "^2.5.7",
41-
"prop-types": "^15.6.1",
41+
"prop-types": "^15.6.2",
4242
"react-perfect-scrollbar": "^1.1.1",
4343
"react-router-dom": "^4.3.1",
4444
"reactstrap": "^6.1.0"

src/Breadcrumb.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react';
2-
import { Route, Link } from 'react-router-dom';
2+
import { Route, Link, matchPath } from 'react-router-dom';
33
import { Breadcrumb, BreadcrumbItem } from 'reactstrap';
44
import PropTypes from 'prop-types';
55
import classNames from 'classnames';
@@ -20,11 +20,8 @@ const getPaths = (pathname) => {
2020
};
2121

2222
const findRouteName = (url) => {
23-
const aroute = routes.find(route => route.path === url);
24-
if (aroute && aroute.name) {
25-
return aroute.name;
26-
}
27-
return null;
23+
const aroute = routes.find(route => matchPath(url, {path: route.path, exact: route.exact}));
24+
return (aroute && aroute.name) ? aroute.name : null
2825
};
2926

3027
const BreadcrumbsItem = ({ match }) => {

0 commit comments

Comments
 (0)