-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Fix NPM packages name validation #26595
Changes from 3 commits
c4bab2c
0bb5520
cdad9f0
b82d53b
87789ae
f1fbb42
712ac64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,16 @@ func TestParsePackage(t *testing.T) { | |
test(t, " test") | ||
test(t, "test ") | ||
test(t, "te st") | ||
test(t, "Test") | ||
test(t, "_test") | ||
test(t, ".test") | ||
test(t, "^test") | ||
test(t, "te^st") | ||
test(t, "te|st") | ||
test(t, "te)(st") | ||
test(t, "te'st") | ||
test(t, "te!st") | ||
test(t, "te*st") | ||
test(t, "invalid/scope") | ||
test(t, "@invalid/_name") | ||
test(t, "@invalid/.name") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should also test for
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could keep a map of reserved names. Would be cleaner then extending the regex. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One doesn't exclude the other? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we merge this PR without reserved names inspection feature? |
||
|
@@ -93,6 +103,13 @@ func TestParsePackage(t *testing.T) { | |
|
||
test(t, "test") | ||
test(t, "@scope/name") | ||
test(t, "@scope/q") | ||
test(t, "q") | ||
test(t, "@scope/package-name") | ||
test(t, "@scope/package.name") | ||
test(t, "@scope/package_name") | ||
test(t, "123name") | ||
test(t, "----") | ||
test(t, packageFullName) | ||
}) | ||
|
||
|
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.
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.
Thanks! Added test for that case and applied suggested solution.