Skip to content

Commit

Permalink
Update error message for requested/resolved mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Feb 5, 2020
1 parent 0162efd commit 3d0bfea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/next/next-server/server/normalize-page-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export function normalizePagePath(page: string): string {
// Throw when using ../ etc in the pathname
const resolvedPage = posix.normalize(page)
if (page !== resolvedPage) {
throw new Error('Requested and resolved page mismatch')
throw new Error(
`Requested and resolved page mismatch: ${page} ${resolvedPage}`
)
}
return page
}
3 changes: 2 additions & 1 deletion packages/next/server/on-demand-entry-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,11 @@ export default function onDemandEntryHandler(
throw pageNotFoundError(normalizedPagePath)
}

let pageUrl = `/${pagePath
let pageUrl = `${pagePath[0] !== '/' ? '/' : ''}${pagePath
.replace(new RegExp(`\\.+(?:${pageExtensions.join('|')})$`), '')
.replace(/\\/g, '/')}`.replace(/\/index$/, '')
pageUrl = pageUrl === '' ? '/' : pageUrl

const bundleFile = `${normalizePagePath(pageUrl)}.js`
const name = join('static', buildId, 'pages', bundleFile)
const absolutePagePath = pagePath.startsWith('next/dist/pages')
Expand Down

0 comments on commit 3d0bfea

Please sign in to comment.