Skip to content

Commit

Permalink
fix(router,routerTypes): relax path comparison
Browse files Browse the repository at this point in the history
* router, disable return the default nav details
* routerHelpers, trim trailing slash
  • Loading branch information
cdcabrera committed Feb 12, 2020
1 parent d283917 commit 980e859
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ class Router extends React.Component {
exact={item.hasParameters || item.exact}
key={item.to}
path={item.to}
strict={item.strict}
render={routeProps => {
const navDetail = routerHelpers.getNavigationDetail({
pathname: routeProps.location && routeProps.location.pathname,
returnDefault: true
returnDefault: false
});

return (
Expand Down
4 changes: 3 additions & 1 deletion src/components/router/routerHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const getNavigationDetail = ({ id = null, pathname = null, returnDefault = false
}

if (!navigationItem && pathname) {
navigationItem = navigation.find(item => item.path === pathname) || (returnDefault && defaultItem);
navigationItem =
navigation.find(item => item.path.replace(/\/$/, '') === pathname.replace(/\/$/, '')) ||
(returnDefault && defaultItem);
}

if (!navigationItem && returnDefault) {
Expand Down

0 comments on commit 980e859

Please sign in to comment.