From 75dc4a47e2f021ad870bba0dfdf3d8d29bbf3b33 Mon Sep 17 00:00:00 2001 From: adventure-yunfei Date: Thu, 25 Aug 2022 19:47:46 +0800 Subject: [PATCH] fix(core): preload should support encoded page links (#7977) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Lorber Co-authored-by: sebastienlorber --- packages/docusaurus/src/client/preload.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus/src/client/preload.ts b/packages/docusaurus/src/client/preload.ts index fec374ad4b..1411581742 100644 --- a/packages/docusaurus/src/client/preload.ts +++ b/packages/docusaurus/src/client/preload.ts @@ -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 { - 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?.())); }