From 63782b72df56592d3eaa846f83cb3ad0d2f23917 Mon Sep 17 00:00:00 2001 From: Eg0ld <80466939+Eg0ld@users.noreply.github.com> Date: Mon, 4 Nov 2024 07:46:28 -0500 Subject: [PATCH] Revert "fix: invalid input with initial underscore (#1254)" This reverts commit db35260e84b2e05a5b0afbd1ec587c58a7d5f3f5. --- .../define-remix-app/src/define-remix-app.tsx | 6 +++--- .../define-remix-app/test/define-remix.spec.ts | 17 +++++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/define-remix-app/src/define-remix-app.tsx b/packages/define-remix-app/src/define-remix-app.tsx index 3ec48868..df862d09 100644 --- a/packages/define-remix-app/src/define-remix-app.tsx +++ b/packages/define-remix-app/src/define-remix-app.tsx @@ -105,17 +105,17 @@ export default function defineRemixApp({ appPath, routingPattern = 'file' }: IDe }) .join('.'); const pageName = toCamelCase(pageFileName); - if (!pageName && !requestedURI) { + if (!pageName) { return { isValid: false, errorMessage: INVALID_MSGS.emptyName, pageModule: '', newPageSourceCode: '', }; - } else if (!(pageName[0] || requestedURI[0]).match(/[A-Za-z]/)) { + } else if (!pageName[0].match(/[A-Za-z]/)) { return { isValid: false, - errorMessage: INVALID_MSGS.initialPageLetter, + errorMessage: 'Page names must start with a letter of the alphabet', pageModule: '', newPageSourceCode: '', }; diff --git a/packages/define-remix-app/test/define-remix.spec.ts b/packages/define-remix-app/test/define-remix.spec.ts index bb4fb105..a2aae075 100644 --- a/packages/define-remix-app/test/define-remix.spec.ts +++ b/packages/define-remix-app/test/define-remix.spec.ts @@ -1024,17 +1024,14 @@ describe('define-remix', () => { [indexPath]: simpleLayout, }); - const invalidCases = ['1st-page', '_about']; - for (const invalidCase of invalidCases) { - const { isValid, errorMessage, pageModule, newPageRoute, newPageSourceCode } = - driver.getNewPageInfo(invalidCase); + const { isValid, errorMessage, pageModule, newPageRoute, newPageSourceCode } = + driver.getNewPageInfo('1st-page'); - expect(isValid, `isValid ${invalidCase}`).to.eql(false); - expect(errorMessage, `error message ${invalidCase}`).to.eql(INVALID_MSGS.initialPageLetter); - expect(pageModule, `page module ${invalidCase}`).to.eql(''); - expect(newPageSourceCode, `newPageSourceCode ${invalidCase}`).to.eql(''); - expect(newPageRoute, `newPageRoute ${invalidCase}`).to.eql(undefined); - } + expect(isValid, 'isValid').to.eql(false); + expect(errorMessage, 'error message').to.eql(INVALID_MSGS.initialPageLetter); + expect(pageModule, 'page module').to.eql(''); + expect(newPageSourceCode, 'newPageSourceCode').to.eql(''); + expect(newPageRoute, 'newPageRoute').to.eql(undefined); }); it('should limit route param key', async () => { const { driver } = await getInitialManifest({