From 93997587d816cb7acab13c20807c97de87784dac Mon Sep 17 00:00:00 2001 From: Raj Nigam Date: Wed, 10 Jun 2020 01:35:11 -0400 Subject: [PATCH] support optional catch-all routes Next.js added a new, experimental, [optional catch-all routes](https://nextjs.org/docs/api-routes/dynamic-api-routes#optional-catch-all-api-routes), this adds support for it by looking for one more wrapping square bracket --- lib/getNetlifyRoute.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/getNetlifyRoute.js b/lib/getNetlifyRoute.js index b3f899e..79378e8 100644 --- a/lib/getNetlifyRoute.js +++ b/lib/getNetlifyRoute.js @@ -9,7 +9,7 @@ // also handles catch all routes /[...param]/ -> /:* module.exports = dynamicRoute => { // replace any catch all group first - const expressified = dynamicRoute.replace(/\[\.\.\.(.*)]$/, "*"); + const expressified = dynamicRoute.replace(/\[{1,2}\.{3}(.*)]{1,2}$/, "*"); // now replace other dynamic route groups return expressified.replace(/\[(.*?)]/g, ":$1");