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
bd24b70d
Unverified
Commit
bd24b70d
authored
Jun 27, 2020
by
Jan Potoms
Committed by
GitHub
Jun 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix trailing slash handling in exporting pages with getStaticPaths (#14620)
Fixes
https://github.com/vercel/next.js/issues/14573
parent
3909c76c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
utils.ts
packages/next/build/utils.ts
+2
-0
[slug].js
test/integration/export/pages/gssp/[slug].js
+14
-0
index.test.js
test/integration/export/test/index.test.js
+14
-0
No files found.
packages/next/build/utils.ts
View file @
bd24b70d
...
@@ -24,6 +24,7 @@ import { findPageFile } from '../server/lib/find-page-file'
...
@@ -24,6 +24,7 @@ import { findPageFile } from '../server/lib/find-page-file'
import
{
GetStaticPaths
}
from
'next/types'
import
{
GetStaticPaths
}
from
'next/types'
import
{
denormalizePagePath
}
from
'../next-server/server/normalize-page-path'
import
{
denormalizePagePath
}
from
'../next-server/server/normalize-page-path'
import
{
BuildManifest
}
from
'../next-server/server/get-page-files'
import
{
BuildManifest
}
from
'../next-server/server/get-page-files'
import
{
normalizeTrailingSlash
}
from
'../next-server/lib/router/normalize-trailing-slash'
const
fileGzipStats
:
{
[
k
:
string
]:
Promise
<
number
>
}
=
{}
const
fileGzipStats
:
{
[
k
:
string
]:
Promise
<
number
>
}
=
{}
const
fsStatGzip
=
(
file
:
string
)
=>
{
const
fsStatGzip
=
(
file
:
string
)
=>
{
...
@@ -573,6 +574,7 @@ export async function buildStaticPaths(
...
@@ -573,6 +574,7 @@ export async function buildStaticPaths(
// For a string-provided path, we must make sure it matches the dynamic
// For a string-provided path, we must make sure it matches the dynamic
// route.
// route.
if
(
typeof
entry
===
'string'
)
{
if
(
typeof
entry
===
'string'
)
{
entry
=
normalizeTrailingSlash
(
entry
)
const
result
=
_routeMatcher
(
entry
)
const
result
=
_routeMatcher
(
entry
)
if
(
!
result
)
{
if
(
!
result
)
{
throw
new
Error
(
throw
new
Error
(
...
...
test/integration/export/pages/gssp/[slug].js
0 → 100644
View file @
bd24b70d
export
async
function
getStaticPaths
()
{
return
{
paths
:
[
'/gssp/foo/'
],
fallback
:
false
,
}
}
export
async
function
getStaticProps
({
params
})
{
return
{
props
:
params
}
}
export
default
function
Page
({
slug
})
{
return
`Hello
${
slug
}
`
}
test/integration/export/test/index.test.js
View file @
bd24b70d
...
@@ -103,6 +103,20 @@ describe('Static Export', () => {
...
@@ -103,6 +103,20 @@ describe('Static Export', () => {
).
toBe
(
true
)
).
toBe
(
true
)
})
})
it
(
'should handle trailing slash in getStaticPaths'
,
async
()
=>
{
expect
(
await
access
(
join
(
outdir
,
'gssp/foo/index.html'
))
.
then
(()
=>
true
)
.
catch
(()
=>
false
)
).
toBe
(
true
)
expect
(
await
access
(
join
(
outNoTrailSlash
,
'gssp/foo.html'
))
.
then
(()
=>
true
)
.
catch
(()
=>
false
)
).
toBe
(
true
)
})
it
(
'should only output 404.html without exportTrailingSlash'
,
async
()
=>
{
it
(
'should only output 404.html without exportTrailingSlash'
,
async
()
=>
{
expect
(
expect
(
await
access
(
join
(
outNoTrailSlash
,
'404/index.html'
))
await
access
(
join
(
outNoTrailSlash
,
'404/index.html'
))
...
...
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