Use the new matchPath instead of matchPattern

This commit is contained in:
Kimmo Puputti 2017-02-14 09:50:08 +02:00
parent be2fcdf793
commit 10d6d19c00

View file

@ -1,10 +1,6 @@
import React from 'react';
import { find } from 'lodash';
import { Redirect } from 'react-router-dom';
// This will change to `matchPath` soonish
import matchPattern from 'react-router-dom/matchPattern';
import { Redirect, matchPath } from 'react-router-dom';
import pathToRegexp from 'path-to-regexp';
import {
AuthenticationPage,
@ -286,7 +282,7 @@ const matchRoutesToLocation = (routes, location, matchedRoutes = [], params = {}
routes.forEach(route => {
const { exactly = false } = route;
const match = !route.pattern ? true : matchPattern(route.pattern, location, exactly);
const match = !route.pattern || matchPath(location.pathname, route.pattern, { exact: exactly });
if (match) {
matched.push(route);