File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ function validate (name) {
3030 errors . push ( 'name length must be greater than zero' )
3131 }
3232
33- if ( name . match ( / ^ \. / ) ) {
33+ if ( name . startsWith ( '.' ) ) {
3434 errors . push ( 'name cannot start with a period' )
3535 }
3636
@@ -75,6 +75,11 @@ function validate (name) {
7575 if ( nameMatch ) {
7676 var user = nameMatch [ 1 ]
7777 var pkg = nameMatch [ 2 ]
78+
79+ if ( pkg . startsWith ( '.' ) ) {
80+ errors . push ( 'name cannot start with a period' )
81+ }
82+
7883 if ( encodeURIComponent ( user ) === user && encodeURIComponent ( pkg ) === pkg ) {
7984 return done ( warnings , errors )
8085 }
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