未验证 提交 e50620b9 编写于 作者: J Jan Potoms 提交者: GitHub

Use memoizedPagechecker (#13191)

It seems like this was supposed to use the memoized version of `pageChecker`. I also updated the function to memoize promises instead of promise results. Just in case this function ever gets called concurrently.
上级 ed2ca820
......@@ -162,12 +162,12 @@ export default class Router {
parsedUrl: UrlWithParsedQuery
): Promise<boolean> {
// memoize page check calls so we don't duplicate checks for pages
const pageChecks: { [name: string]: boolean } = {}
const pageChecks: { [name: string]: Promise<boolean> } = {}
const memoizedPageChecker = async (p: string): Promise<boolean> => {
if (pageChecks[p]) {
return pageChecks[p]
}
const result = await this.pageChecker(p)
const result = this.pageChecker(p)
pageChecks[p] = result
return result
}
......@@ -200,7 +200,7 @@ export default class Router {
if (!pathname) {
return { finished: false }
}
if (await this.pageChecker(pathname)) {
if (await memoizedPageChecker(pathname)) {
return this.catchAllRoute.fn(req, res, params, parsedUrl)
}
return { finished: false }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册