Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Commit fc738b4

Browse files
committed
Update dynamic route regex for catch all
1 parent e8adac6 commit fc738b4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Copied from serverless-next.js (v1.8.0)
22
// https://github.com/danielcondemarin/serverless-next.js/blob/master/packages/serverless-nextjs-component/lib/expressifyDynamicRoute.js
33

4-
// converts a nextjs dynamic route /[param]/ to express style /:param/
54
module.exports = dynamicRoute => {
6-
return dynamicRoute.replace(/\[(?<param>.*?)]/g, ":$<param>");
5+
// replace any catch all group first
6+
let expressified = dynamicRoute.replace(/\[\.\.\.(.*)]$/, ":$1*");
7+
8+
// now replace other dynamic route groups
9+
return expressified.replace(/\[(.*?)]/g, ":$1");
710
};

0 commit comments

Comments
 (0)