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
a30e94f2
Unverified
Commit
a30e94f2
authored
Feb 19, 2020
by
Joe Haddad
Committed by
GitHub
Feb 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Nested Index Dynamic Routes in Development (#10595)
* Fix Nested Index Dynamic Routes in Development * add missing
parent
72a461f9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
7 deletions
+88
-7
next-dev-server.ts
packages/next/server/next-dev-server.ts
+6
-7
index.js
test/integration/dynamic-routing/pages/index.js
+12
-0
index.js
...mic-routing/pages/p1/p2/nested-all-ssg/[...rest]/index.js
+15
-0
styles.module.css
...ng/pages/p1/p2/nested-all-ssg/[...rest]/styles.module.css
+3
-0
index.test.js
test/integration/dynamic-routing/test/index.test.js
+52
-0
No files found.
packages/next/server/next-dev-server.ts
View file @
a30e94f2
...
...
@@ -140,6 +140,10 @@ export default class DevServer extends Server {
return
}
const
regexPageExtension
=
new
RegExp
(
`\\.+(?:
${
this
.
nextConfig
.
pageExtensions
.
join
(
'|'
)}
)$`
)
let
resolved
=
false
return
new
Promise
(
resolve
=>
{
const
pagesDir
=
this
.
pagesDir
...
...
@@ -163,18 +167,13 @@ export default class DevServer extends Server {
const
dynamicRoutedPages
=
[]
const
knownFiles
=
wp
.
getTimeInfoEntries
()
for
(
const
[
fileName
,
{
accuracy
}]
of
knownFiles
)
{
if
(
accuracy
===
undefined
)
{
if
(
accuracy
===
undefined
||
!
regexPageExtension
.
test
(
fileName
)
)
{
continue
}
let
pageName
=
'/'
+
relative
(
pagesDir
!
,
fileName
).
replace
(
/
\\
+/g
,
'/'
)
pageName
=
pageName
.
replace
(
new
RegExp
(
`\\.+(?:
${
this
.
nextConfig
.
pageExtensions
.
join
(
'|'
)}
)$`
),
''
)
pageName
=
pageName
.
replace
(
regexPageExtension
,
''
)
pageName
=
pageName
.
replace
(
/
\/
index$/
,
''
)
||
'/'
if
(
!
isDynamicRoute
(
pageName
))
{
...
...
test/integration/dynamic-routing/pages/index.js
View file @
a30e94f2
...
...
@@ -44,6 +44,18 @@ const Page = () => (
<
Link
href
=
"/p1/p2/all-ssg/[...rest]"
as
=
"/p1/p2/all-ssg/hello1/hello2"
>
<
a
id
=
"ssg-catch-all-multi"
>
Catch
-
all
route
(
multi
)
<
/a
>
<
/Link
>
<
Link
href
=
"/p1/p2/nested-all-ssg/[...rest]"
as
=
"/p1/p2/nested-all-ssg/hello"
>
<
a
id
=
"nested-ssg-catch-all-single"
>
Nested
Catch
-
all
route
(
single
)
<
/a
>
<
/Link
>
<
Link
href
=
"/p1/p2/nested-all-ssg/[...rest]"
as
=
"/p1/p2/nested-all-ssg/hello1/hello2"
>
<
a
id
=
"nested-ssg-catch-all-multi"
>
Nested
Catch
-
all
route
(
multi
)
<
/a
>
<
/Link
>
<
/div
>
)
...
...
test/integration/dynamic-routing/pages/p1/p2/nested-all-ssg/[...rest]/index.js
0 → 100644
View file @
a30e94f2
import
styles
from
'./styles.module.css'
function
All
({
params
})
{
return
(
<
div
id
=
"nested-all-ssg-content"
className
=
{
styles
.
test
}
>
{
JSON
.
stringify
(
params
)}
<
/div
>
)
}
export
function
unstable_getStaticProps
({
params
})
{
return
{
props
:
{
params
}
}
}
export
default
All
test/integration/dynamic-routing/pages/p1/p2/nested-all-ssg/[...rest]/styles.module.css
0 → 100644
View file @
a30e94f2
.test
{
color
:
red
;
}
test/integration/dynamic-routing/test/index.test.js
View file @
a30e94f2
...
...
@@ -257,6 +257,24 @@ function runTests(dev) {
})
})
it
(
'[nested ssg: catch all] should pass param in getStaticProps during SSR'
,
async
()
=>
{
const
data
=
await
renderViaHTTP
(
appPort
,
`/_next/data/
${
buildId
}
/p1/p2/nested-all-ssg/test1.json`
)
expect
(
JSON
.
parse
(
data
).
pageProps
.
params
).
toEqual
({
rest
:
[
'test1'
]
})
})
it
(
'[nested ssg: catch all] should pass params in getStaticProps during SSR'
,
async
()
=>
{
const
data
=
await
renderViaHTTP
(
appPort
,
`/_next/data/
${
buildId
}
/p1/p2/nested-all-ssg/test1/test2.json`
)
expect
(
JSON
.
parse
(
data
).
pageProps
.
params
).
toEqual
({
rest
:
[
'test1'
,
'test2'
],
})
})
it
(
'[predefined ssg: catch all] should pass param in getStaticProps during SSR'
,
async
()
=>
{
const
data
=
await
renderViaHTTP
(
appPort
,
...
...
@@ -321,6 +339,34 @@ function runTests(dev) {
}
})
it
(
'[nested ssg: catch-all] should pass params in getStaticProps during client navigation (single)'
,
async
()
=>
{
let
browser
try
{
browser
=
await
webdriver
(
appPort
,
'/'
)
await
browser
.
elementByCss
(
'#nested-ssg-catch-all-single'
).
click
()
await
browser
.
waitForElementByCss
(
'#nested-all-ssg-content'
)
const
text
=
await
browser
.
elementByCss
(
'#nested-all-ssg-content'
).
text
()
expect
(
text
).
toBe
(
'{"rest":["hello"]}'
)
}
finally
{
if
(
browser
)
await
browser
.
close
()
}
})
it
(
'[nested ssg: catch-all] should pass params in getStaticProps during client navigation (multi)'
,
async
()
=>
{
let
browser
try
{
browser
=
await
webdriver
(
appPort
,
'/'
)
await
browser
.
elementByCss
(
'#nested-ssg-catch-all-multi'
).
click
()
await
browser
.
waitForElementByCss
(
'#nested-all-ssg-content'
)
const
text
=
await
browser
.
elementByCss
(
'#nested-all-ssg-content'
).
text
()
expect
(
text
).
toBe
(
'{"rest":["hello1","hello2"]}'
)
}
finally
{
if
(
browser
)
await
browser
.
close
()
}
})
it
(
'should update dynamic values on mount'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
appPort
,
'/on-mount/post-1'
)
expect
(
html
).
toMatch
(
/onmpost:.*pending/
)
...
...
@@ -465,6 +511,12 @@ function runTests(dev) {
page
:
'/p1/p2/all-ssr/[...rest]'
,
regex
:
normalizeRegEx
(
'^
\\
/p1
\\
/p2
\\
/all
\\
-ssr
\\
/(.+?)(?:
\\
/)?$'
),
},
{
page
:
'/p1/p2/nested-all-ssg/[...rest]'
,
regex
:
normalizeRegEx
(
'^
\\
/p1
\\
/p2
\\
/nested
\\
-all
\\
-ssg
\\
/(.+?)(?:
\\
/)?$'
),
},
{
page
:
'/p1/p2/predefined-ssg/[...rest]'
,
regex
:
normalizeRegEx
(
...
...
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