From 751aae38d43dde51be247bf166c8fc9d62d12393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Sun, 11 Mar 2018 07:09:27 +0700 Subject: [PATCH] fix: dynamic routes must start with an underscore Folders or files within `pages/` should only lead to dynamic routes, if they start with an underscore. Previously, folders like `some_folder` would lead to a route parameter `folder` being introduced. --- lib/common/utils.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/common/utils.mjs b/lib/common/utils.mjs index 6980bac494..91df8bb262 100644 --- a/lib/common/utils.mjs +++ b/lib/common/utils.mjs @@ -297,8 +297,13 @@ export const createRoutes = function createRoutes(files, srcDir, pagesDir) { if (key === 'index' && i + 1 === keys.length) { route.path += i > 0 ? '' : '/' } else { - route.path += '/' + (key === '_' ? '*' : key.replace('_', ':')) - if (key !== '_' && key.indexOf('_') !== -1) { + route.path += '/' + + (key === '_' + ? '*' + : key.indexOf('_') === 0 + ? key.replace('_', ':') + : key) + if (key !== '_' && key.indexOf('_') === 0) { route.path += '?' } }