To achieve your goal you can use redux-router
This library allows you to save the state of your router in your Redux repository. Thus, retrieving the current path, query, and parameters is as simple as selecting any other part of your application state.
export const someMiddleware = store => next => action=> {
let params = store.getState().router.params;
next(action)
};