Skip to content

Commit

Permalink
fix(core): preload should support encoded page links (#7977)
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
  • Loading branch information
3 people committed Sep 1, 2022
1 parent 41aa801 commit 27e3b98
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/docusaurus/src/client/preload.ts
Expand Up @@ -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 = Array.from(new Set([pathname, decodeURI(pathname)]))
.map((p) => matchRoutes(routes, p))
.flat();

return Promise.all(matches.map((match) => match.route.component.preload?.()));
}

0 comments on commit 27e3b98

Please sign in to comment.