Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
563f3c08
Unverified
Commit
563f3c08
authored
Jan 15, 2020
by
JJ Kasper
Committed by
GitHub
Jan 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Honor exportTrailingSlash for default 404 (#10109)
parent
d6721676
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
10 deletions
+38
-10
index.ts
packages/next/export/index.ts
+2
-2
ssr.js
test/integration/export-serverless/test/ssr.js
+2
-2
index.test.js
test/integration/export/test/index.test.js
+31
-4
ssr.js
test/integration/export/test/ssr.js
+3
-2
No files found.
packages/next/export/index.ts
View file @
563f3c08
...
...
@@ -254,8 +254,8 @@ export default async function(
distDir
,
buildId
,
})
if
(
!
exportPathMap
[
'/404'
])
{
exportPathMap
[
'/404
.html'
]
=
exportPathMap
[
'/404.html'
]
||
{
if
(
!
exportPathMap
[
'/404'
]
&&
!
exportPathMap
[
'/404.html'
]
)
{
exportPathMap
[
'/404
'
]
=
exportPathMap
[
'/404.html'
]
=
{
page
:
'/_error'
,
}
}
...
...
test/integration/export-serverless/test/ssr.js
View file @
563f3c08
...
...
@@ -58,11 +58,11 @@ export default function(context) {
expect
(
html
).
toMatch
(
/404.*page.*not.*found/i
)
})
it
(
'should
not
render _error on /404/index.html'
,
async
()
=>
{
it
(
'should render _error on /404/index.html'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
context
.
port
,
'/404/index.html'
)
// The default error page from the test server
// contains "404", so need to be specific here
expect
(
html
).
not
.
toMatch
(
/404.*page.*not.*found/i
)
expect
(
html
).
toMatch
(
/404.*page.*not.*found/i
)
})
it
(
'Should serve static files'
,
async
()
=>
{
...
...
test/integration/export/test/index.test.js
View file @
563f3c08
...
...
@@ -27,6 +27,8 @@ const writeFile = promisify(fs.writeFile)
const
mkdir
=
promisify
(
fs
.
mkdir
)
const
access
=
promisify
(
fs
.
access
)
const
appDir
=
join
(
__dirname
,
'../'
)
const
outdir
=
join
(
appDir
,
'out'
)
const
outNoTrailSlash
=
join
(
appDir
,
'outNoTrailSlash'
)
const
context
=
{}
context
.
appDir
=
appDir
const
devContext
=
{}
...
...
@@ -34,7 +36,6 @@ const nextConfig = new File(join(appDir, 'next.config.js'))
describe
(
'Static Export'
,
()
=>
{
it
(
'should delete existing exported files'
,
async
()
=>
{
const
outdir
=
join
(
appDir
,
'out'
)
const
tempfile
=
join
(
outdir
,
'temp.txt'
)
await
mkdir
(
outdir
).
catch
(
e
=>
{
...
...
@@ -52,9 +53,6 @@ describe('Static Export', () => {
expect
(
doesNotExist
).
toBe
(
true
)
})
beforeAll
(
async
()
=>
{
const
outdir
=
join
(
appDir
,
'out'
)
const
outNoTrailSlash
=
join
(
appDir
,
'outNoTrailSlash'
)
await
nextBuild
(
appDir
)
await
nextExport
(
appDir
,
{
outdir
})
...
...
@@ -93,6 +91,35 @@ describe('Static Export', () => {
])
})
it
(
'should honor exportTrailingSlash for 404 page'
,
async
()
=>
{
expect
(
await
access
(
join
(
outdir
,
'404/index.html'
))
.
then
(()
=>
true
)
.
catch
(()
=>
false
)
).
toBe
(
true
)
// we still output 404.html for backwards compat
expect
(
await
access
(
join
(
outdir
,
'404.html'
))
.
then
(()
=>
true
)
.
catch
(()
=>
false
)
).
toBe
(
true
)
})
it
(
'should only output 404.html without exportTrailingSlash'
,
async
()
=>
{
expect
(
await
access
(
join
(
outNoTrailSlash
,
'404/index.html'
))
.
then
(()
=>
true
)
.
catch
(()
=>
false
)
).
toBe
(
false
)
expect
(
await
access
(
join
(
outNoTrailSlash
,
'404.html'
))
.
then
(()
=>
true
)
.
catch
(()
=>
false
)
).
toBe
(
true
)
})
ssr
(
context
)
browser
(
context
)
dev
(
devContext
)
...
...
test/integration/export/test/ssr.js
View file @
563f3c08
...
...
@@ -58,11 +58,12 @@ export default function(context) {
expect
(
html
).
toMatch
(
/404.*page.*not.*found/i
)
})
it
(
'should not render _error on /404/index.html'
,
async
()
=>
{
// since exportTrailingSlash is enabled we should allow this
it
(
'should render _error on /404/index.html'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
context
.
port
,
'/404/index.html'
)
// The default error page from the test server
// contains "404", so need to be specific here
expect
(
html
).
not
.
toMatch
(
/404.*page.*not.*found/i
)
expect
(
html
).
toMatch
(
/404.*page.*not.*found/i
)
})
it
(
'Should serve static files'
,
async
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment