Skip to content

Commit 00d930a

Browse files
ijjkTimer
andauthored
Add additional file serving tests (vercel#12479)
* Test `static/` file name encoding * Fix `static/` file name encoding * Add additional file-serving tests * bump Co-authored-by: Joe Haddad <[email protected]>
1 parent 3af0fe5 commit 00d930a

File tree

10 files changed

+4502
-3
lines changed

10 files changed

+4502
-3
lines changed

packages/next/server/next-dev-server.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,21 @@ export default class DevServer extends Server {
272272
}
273273

274274
protected async hasPage(pathname: string): Promise<boolean> {
275+
let normalizedPath: string
276+
277+
try {
278+
normalizedPath = normalizePagePath(pathname)
279+
} catch (err) {
280+
console.error(err)
281+
// if normalizing the page fails it means it isn't valid
282+
// so it doesn't exist so don't throw and return false
283+
// to ensure we return 404 instead of 500
284+
return false
285+
}
286+
275287
const pageFile = await findPageFile(
276288
this.pagesDir!,
277-
normalizePagePath(pathname),
289+
normalizedPath,
278290
this.nextConfig.pageExtensions
279291
)
280292
return !!pageFile

test-file.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
this is used for traverse testing
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default () => 'hi'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
this is used for traverse testing

0 commit comments

Comments
 (0)