More accurate package.json name regex #331
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This issue was originally posted at aspnet/JavaScriptServices#1232.
As of VS2017, the package.json
name
field is required to match the regex^[^A-Z]+$
and have a length not more than 214 characters.I propose that this regex be changed to
This regex follows the guidelines at https://docs.npmjs.com/files/package.json better. I have added some simple unit tests for it over at https://regex101.com/r/QgADad/3/tests.
The following lines can also be handled by the regex itself by prepending
(?=.{1,214}$)
, but I have not made this change in case these fields serve other purposes too.Please let me know if you would like me to clarify the regex in any way. It is much more complex than the existing one, but also more accurate.
Ref:
https://stackoverflow.com/questions/695438/safe-characters-for-friendly-url
https://stackoverflow.com/questions/11197549/regular-expression-limit-string-size