Skip to content

Commit

Permalink
Stop mutating resolvedAsPath (#23705)
Browse files Browse the repository at this point in the history
Follow up to #23614. `resolvedAsPath` isn't actually even being used as an output, we're just mutating it for convenience. If we do want to output it in the future, we can do it a different way (i.e. via return).
  • Loading branch information
devknoll committed Apr 5, 2021
1 parent 8fdcc52 commit 63b96b1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/next/next-server/server/render.tsx
Expand Up @@ -496,6 +496,8 @@ export async function renderToHTML(
)
}

let asPath: string = renderOpts.resolvedAsPath || (req.url as string)

if (dev) {
const { isValidElementType } = require('react-is')
if (!isValidElementType(Component)) {
Expand Down Expand Up @@ -525,7 +527,7 @@ export async function renderToHTML(
}
: {}),
}
renderOpts.resolvedAsPath = `${pathname}${
asPath = `${pathname}${
// ensure trailing slash is present for non-dynamic auto-export pages
req.url!.endsWith('/') && pathname !== '/' && !pageIsDynamic ? '/' : ''
}`
Expand Down Expand Up @@ -561,7 +563,6 @@ export async function renderToHTML(
}

// url will always be set
const asPath: string = renderOpts.resolvedAsPath || (req.url as string)
const routerIsReady = !!(getServerSideProps || hasPageGetInitialProps)
const router = new ServerRouter(
pathname,
Expand Down

0 comments on commit 63b96b1

Please sign in to comment.