From 59d739a66a404b1e0c74587b87461078460ba74f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20B=C3=BCttner?= Date: Thu, 28 Mar 2024 12:06:21 +0100 Subject: [PATCH] publish 1.2.2 --- package.json | 2 +- src/generate-folders.ts | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ce5f0cd..5cd548b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@idrinth/react-file-based-routes", - "version": "1.2.1", + "version": "1.2.2", "repository": "https://github.com/idrinth/react-file-based-routes", "description": "A simple file based routing library, that does not force itself on you.", "license": "MIT", diff --git a/src/generate-folders.ts b/src/generate-folders.ts index 0b30de5..46cb4ab 100644 --- a/src/generate-folders.ts +++ b/src/generate-folders.ts @@ -38,12 +38,16 @@ export default (cwd: string, configuration: Configuration) => { const content = readFileSync(cwd + '/' + configuration.fileFinder.distJSRoot + '/' + file, 'utf8',); const res = matcher.exec(content); if (res && res[1]) { - if (typeof configuration.routes.overridePathMappings[res[1]] === 'string') { - if (configuration.routes.overridePathMappings[res[1]] !== '*') { - writeIndexHtml(cwd, file, configuration.routes.overridePathMappings[res[1]], template, configuration, cssFiles, jsFiles); + const pageName = res[1].replace(/\/$/u, ''); + console.log(pageName); + if (typeof configuration.routes.overridePathMappings[pageName] === 'string') { + if (configuration.routes.overridePathMappings[pageName] !== '*') { + writeIndexHtml(cwd, file, configuration.routes.overridePathMappings[pageName], template, configuration, cssFiles, jsFiles); + } else { + writeIndexHtml(cwd, file, '', template, configuration, cssFiles, jsFiles); } } else { - writeIndexHtml(cwd, file, `/${ res[1] }/`, template, configuration, cssFiles, jsFiles); + writeIndexHtml(cwd, file, `/${ pageName }/`, template, configuration, cssFiles, jsFiles); } } }