Skip to content

Commit

Permalink
Revert "fix: invalid input with initial underscore (#1254)"
Browse files Browse the repository at this point in the history
This reverts commit db35260.
  • Loading branch information
Eg0ld authored Nov 4, 2024
1 parent db35260 commit 63782b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions packages/define-remix-app/src/define-remix-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
};
Expand Down
17 changes: 7 additions & 10 deletions packages/define-remix-app/test/define-remix.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 63782b7

Please sign in to comment.