Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
location,
state: routeState,
},
},
}));
return;
}
}
// Check for a redirect and change location if one is found.
let redirect = redirects.getRedirect(location);
if (redirect) {
if (typeof redirect === 'function' || redirect instanceof Promise) {
const { pathname } = getCurrentRoute(state);
LoadingProvider.setLoading(pathname);
const pattern = router.findPattern(location.split('?')[0]);
const { transform } = router.patterns[pattern] || {};
const route = new Route({
pathname: location,
pattern,
routeState,
transform,
});
try {
redirect = await redirect({
...params,
action: {
...params.action,
const changeSortOrder = sort => (dispatch, getState) => {
const { query, state } = getCurrentRoute(getState());
const newQuery = parseObjectToQueryString({
...query,
sort,
});
dispatch(historyReplace({
pathname: `${window.location.pathname}${newQuery}`,
state,
}));
};
const openFilterRoute = () => (dispatch, getState) => {
const {
id,
params: { categoryId },
query,
state,
} = getCurrentRoute(getState());
const forwardState = {
filters: state.filters || null,
parentId: id,
};
if (categoryId) {
dispatch(historyPush({
pathname: `${CATEGORY_PATH}/${categoryId}/filter`,
state: forwardState,
}));
} else if (query.s) {
const queryString = parseObjectToQueryString(query);
dispatch(historyPush({
pathname: `${SEARCH_PATH}/filter${queryString}`,
subscribe(routeDidEnter$, ({ dispatch, getState }) => {
const { pattern } = getCurrentRoute(getState());
dispatch(isTabBarVisible(getState(), pattern) ? enableTabBar() : disableTabBar());
});
export const handleAppRedirect = (historyAction, state) => {
const { pathname } = getCurrentRoute(state);
if (authRoutes.isProtector(pathname) && historyAction === ACTION_REPLACE) {
/**
* A replace action on a protector route indicates that the authentication was successful.
* So the protector route can be popped from the history stack.
*/
router.pop();
}
};
const callPageViewTracker = ({ getState }) => {
const state = getState();
const getTrackingData = makeGetTrackingData();
track(
'pageview',
getTrackingData(state, getCurrentRoute(state)),
state
);
};
.filter(({ getState }) => {
const { pattern } = getCurrentRoute(getState());
return (pattern === SEARCH_PATH);
});
.filter(({ getState }) => {
const { pattern } = getCurrentRoute(getState());
return (pattern === SEARCH_PATH);
});
.filter(({ action, getState }) => {
const route = getCurrentRoute(getState());
if (typeof action.productData === 'undefined' || typeof action.productData.id === 'undefined') {
return false;
}
if (!route.params.productId && !route.state.productId) {
return false;
}
if (route.state.productId) {
return action.productData.id === route.state.productId;
}
return action.productData.id === hex2bin(route.params.productId);
});
.filter(({ getState }) => {
const { pattern } = getCurrentRoute(getState());
return (pattern === `${CATEGORY_PATH}/:categoryId`);
});