-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0d5491
commit 33ab9cc
Showing
11 changed files
with
151 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...rless-nextjs-component/__tests__/fixtures/built-artifact/pages/customers/[...catchAll].js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
render: (req, res) => { | ||
res.end("pages/customers/[...catchAll].js"); | ||
} | ||
}; |
2 changes: 1 addition & 1 deletion
2
...-nextjs-component/__tests__/fixtures/built-artifact/pages/customers/[customer]/profile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
render: (req, res) => { | ||
res.end("pages/[customers]/[customer]/profile.js"); | ||
res.end("pages/customers/[customer]/profile.js"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
packages/serverless-nextjs-component/lib/expressifyDynamicRoute.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
// converts a nextjs dynamic route /[param]/ to express style /:param/ | ||
// converts a nextjs dynamic route /[param]/ -> /:param | ||
// also handles catch all routes /[...param]/ -> /:param* | ||
module.exports = dynamicRoute => { | ||
return dynamicRoute.replace(/\[(?<param>.*?)]/g, ":$<param>"); | ||
// replace any catch all group first | ||
let expressified = dynamicRoute.replace(/\[\.\.\.(.*)]$/, ":$1*"); | ||
|
||
// now replace other dynamic route groups | ||
return expressified.replace(/\[(.*?)]/g, ":$1"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters