File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ function validate (name) {
3030 errors . push ( 'name length must be greater than zero' )
3131 }
3232
33- if ( name . match ( / ^ \. / ) ) {
33+ // cannot start with period, both scoped and unscoped
34+ if ( name . match ( / ^ \. / ) || name . match ( / ^ (?: @ ( [ ^ / ] + ?) [ / ] ) ? ( \. [ ^ / ] * ) $ / ) ) {
3435 errors . push ( 'name cannot start with a period' )
3536 }
3637
Original file line number Diff line number Diff line change @@ -53,6 +53,21 @@ test('validate-npm-package-name', function (t) {
5353 validForOldPackages : false ,
5454 errors : [ 'name cannot start with a period' ] } )
5555
56+ t . same ( validate ( '@npm/.' ) , {
57+ validForNewPackages : false ,
58+ validForOldPackages : false ,
59+ errors : [ 'name cannot start with a period' ] } )
60+
61+ t . same ( validate ( '@npm/..' ) , {
62+ validForNewPackages : false ,
63+ validForOldPackages : false ,
64+ errors : [ 'name cannot start with a period' ] } )
65+
66+ t . same ( validate ( '@npm/.package' ) , {
67+ validForNewPackages : false ,
68+ validForOldPackages : false ,
69+ errors : [ 'name cannot start with a period' ] } )
70+
5671 t . same ( validate ( '_start-with-underscore' ) , {
5772 validForNewPackages : false ,
5873 validForOldPackages : false ,
You can’t perform that action at this time.
0 commit comments