fix: preload with encoded page links

This commit is contained in:
adventure-yunfei 2022-08-18 14:39:44 +08:00
parent eac3239757
commit 021158a02d

View file

@ -17,7 +17,9 @@ import {matchRoutes} from 'react-router-config';
* @returns Promise object represents whether pathname has been preloaded
*/
export default function preload(pathname: string): Promise<void[]> {
const matches = matchRoutes(routes, pathname);
const matches = [pathname, decodeURI(pathname)]
.map(p => matchRoutes(routes, p))
.flat();
return Promise.all(matches.map((match) => match.route.component.preload?.()));
}