Add additional file serving tests (#12479)
* Test `static/` file name encoding * Fix `static/` file name encoding * Add additional file-serving tests * bump Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
This commit is contained in:
parent
3af0fe5cf2
commit
00d930aae8
10 changed files with 4502 additions and 3 deletions
|
@ -272,9 +272,21 @@ export default class DevServer extends Server {
|
|||
}
|
||||
|
||||
protected async hasPage(pathname: string): Promise<boolean> {
|
||||
let normalizedPath: string
|
||||
|
||||
try {
|
||||
normalizedPath = normalizePagePath(pathname)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
// if normalizing the page fails it means it isn't valid
|
||||
// so it doesn't exist so don't throw and return false
|
||||
// to ensure we return 404 instead of 500
|
||||
return false
|
||||
}
|
||||
|
||||
const pageFile = await findPageFile(
|
||||
this.pagesDir!,
|
||||
normalizePagePath(pathname),
|
||||
normalizedPath,
|
||||
this.nextConfig.pageExtensions
|
||||
)
|
||||
return !!pageFile
|
||||
|
|
1
test-file.txt
Normal file
1
test-file.txt
Normal file
|
@ -0,0 +1 @@
|
|||
this is used for traverse testing
|
1
test/integration/file-serving/pages/index.js
Normal file
1
test/integration/file-serving/pages/index.js
Normal file
|
@ -0,0 +1 @@
|
|||
export default () => 'hi'
|
1
test/integration/file-serving/public/hello world.txt
Normal file
1
test/integration/file-serving/public/hello world.txt
Normal file
|
@ -0,0 +1 @@
|
|||
hi
|
1
test/integration/file-serving/static/hello world.txt
Normal file
1
test/integration/file-serving/static/hello world.txt
Normal file
|
@ -0,0 +1 @@
|
|||
hi
|
1
test/integration/file-serving/test-file.txt
Normal file
1
test/integration/file-serving/test-file.txt
Normal file
|
@ -0,0 +1 @@
|
|||
this is used for traverse testing
|
4474
test/integration/file-serving/test/index.test.js
Normal file
4474
test/integration/file-serving/test/index.test.js
Normal file
File diff suppressed because it is too large
Load diff
1
test/integration/test-file.txt
Normal file
1
test/integration/test-file.txt
Normal file
|
@ -0,0 +1 @@
|
|||
this is used for traverse testing
|
|
@ -172,7 +172,10 @@ export function runNextCommandDev(argv, stdOut, opts = {}) {
|
|||
if (typeof opts.onStdout === 'function') {
|
||||
opts.onStdout(message)
|
||||
}
|
||||
process.stdout.write(message)
|
||||
|
||||
if (opts.stdout !== false) {
|
||||
process.stdout.write(message)
|
||||
}
|
||||
}
|
||||
|
||||
function handleStderr(data) {
|
||||
|
@ -180,7 +183,10 @@ export function runNextCommandDev(argv, stdOut, opts = {}) {
|
|||
if (typeof opts.onStderr === 'function') {
|
||||
opts.onStderr(message)
|
||||
}
|
||||
process.stderr.write(message)
|
||||
|
||||
if (opts.stderr !== false) {
|
||||
process.stderr.write(message)
|
||||
}
|
||||
}
|
||||
|
||||
instance.stdout.on('data', handleStdout)
|
||||
|
|
1
test/test-file.txt
Normal file
1
test/test-file.txt
Normal file
|
@ -0,0 +1 @@
|
|||
this is used for traverse testing
|
Loading…
Reference in a new issue