-
Notifications
You must be signed in to change notification settings - Fork 966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check that most generator <name> positional arguments don't start with non-word characters #7143
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - I tested generating / and /foo and both break with the same issue. I tested using \ and \foo and it works fine... Would \ cause any issues on linux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing is new to me... so just to let you know - i added some comments in the code section where I tested using . and , and it messed up the routes file. May be worth validating against these characters, also. I have to go now but may test some more random characters later.
You've got the soul of a real QA person! :) I'll negate the check: instead of checking that the first character isn't from a list of weird ones, I'll check that first character must be a letter or number. |
… numbers or underscore)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added single comment; looks good. I have not compiled and tested.
Co-authored-by: Barrett Burnworth <77902178+pantheredeye@users.noreply.github.com>
…h / (#7143) * Check that the <name> positional argument doesn't start with / * Add tests * Update existing test to include a name * Negate check to make sure names must start with a character (letters, numbers or underscore) * Update packages/cli/src/commands/generate/helpers.js Co-authored-by: Barrett Burnworth <77902178+pantheredeye@users.noreply.github.com> Co-authored-by: Barrett Burnworth <77902178+pantheredeye@users.noreply.github.com>
…h / (#7143) * Check that the <name> positional argument doesn't start with / * Add tests * Update existing test to include a name * Negate check to make sure names must start with a character (letters, numbers or underscore) * Update packages/cli/src/commands/generate/helpers.js Co-authored-by: Barrett Burnworth <77902178+pantheredeye@users.noreply.github.com> Co-authored-by: Barrett Burnworth <77902178+pantheredeye@users.noreply.github.com>
}) | ||
it('does nothing if name is valid', () => { | ||
expect(() => helpers.validateName('foo')).not.toThrow() | ||
expect(() => helpers.validateName('foo/')).not.toThrow() | ||
expect(() => helpers.validateName('_foo')).not.toThrow() | ||
expect(() => helpers.validateName('1foo')).not.toThrow() | ||
expect(() => helpers.validateName('foo/bar')).not.toThrow() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cannikin Thinking about the problem with creating a page in a sub directory. I was checking to update the regex pattern in this PR, but this line tests for a directory/page
and expects no error. 🤷♂️ It seems like this would pass the subdirectory creation pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there's no actual error during the generation, but the page itself, when React tries to render it, throws an error because the route function call is invalid syntax routes.admin / dashboard()
.
Closes #7136