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
9cc8d26a
Commit
9cc8d26a
authored
Jul 09, 2017
by
fridays
Committed by
Arunoda Susiripala
Jul 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix regex for pages that end with index (#2505)
parent
0f3fecfe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
page-loader.js
lib/page-loader.js
+1
-1
pages-plugin.js
server/build/plugins/pages-plugin.js
+3
-1
No files found.
lib/page-loader.js
View file @
9cc8d26a
...
@@ -18,7 +18,7 @@ export default class PageLoader {
...
@@ -18,7 +18,7 @@ export default class PageLoader {
if
(
route
[
0
]
!==
'/'
)
{
if
(
route
[
0
]
!==
'/'
)
{
throw
new
Error
(
'Route name should start with a "/"'
)
throw
new
Error
(
'Route name should start with a "/"'
)
}
}
route
=
route
.
replace
(
/
index$/
,
'
'
)
route
=
route
.
replace
(
/
\/
index$/
,
'/
'
)
if
(
route
===
'/'
)
return
route
if
(
route
===
'/'
)
return
route
return
route
.
replace
(
/
\/
$/
,
''
)
return
route
.
replace
(
/
\/
$/
,
''
)
...
...
server/build/plugins/pages-plugin.js
View file @
9cc8d26a
...
@@ -14,7 +14,7 @@ export default class PagesPlugin {
...
@@ -14,7 +14,7 @@ export default class PagesPlugin {
pages
.
forEach
((
chunk
)
=>
{
pages
.
forEach
((
chunk
)
=>
{
const
page
=
compilation
.
assets
[
chunk
.
name
]
const
page
=
compilation
.
assets
[
chunk
.
name
]
const
pageName
=
MATCH_ROUTE_NAME
.
exec
(
chunk
.
name
)[
1
]
const
pageName
=
MATCH_ROUTE_NAME
.
exec
(
chunk
.
name
)[
1
]
let
routeName
=
`/
${
pageName
.
replace
(
/
[/\\]?
index$/
,
''
)}
`
let
routeName
=
pageName
// We need to convert \ into / when we are in windows
// We need to convert \ into / when we are in windows
// to get the proper route name
// to get the proper route name
...
@@ -26,6 +26,8 @@ export default class PagesPlugin {
...
@@ -26,6 +26,8 @@ export default class PagesPlugin {
routeName
=
routeName
.
replace
(
/
\\
/g
,
'/'
)
routeName
=
routeName
.
replace
(
/
\\
/g
,
'/'
)
}
}
routeName
=
`/
${
routeName
.
replace
(
/
(
^|
\/)
index$/
,
''
)}
`
const
content
=
page
.
source
()
const
content
=
page
.
source
()
const
newContent
=
`
const
newContent
=
`
window.__NEXT_REGISTER_PAGE('
${
routeName
}
', function() {
window.__NEXT_REGISTER_PAGE('
${
routeName
}
', function() {
...
...
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