File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ const { log } = require('proc-log')
14
14
const hasSlashes = isWindows ? / \\ | [ / ] / : / [ / ] /
15
15
const isURL = / ^ (?: g i t [ + ] ) ? [ a - z ] + : / i
16
16
const isGit = / ^ [ ^ @ ] + @ [ ^ : . ] + \. [ ^ : ] + : .+ $ / i
17
- const isFileType = / [ . ] (?: t g z | t a r .g z | t a r ) $ / i
17
+ const isFileType = / [ . ] (?: t g z | t a r \ .g z | t a r ) $ / i
18
18
const isPortNumber = / : [ 0 - 9 ] + ( \/ | $ ) / i
19
19
const isWindowsFile = / ^ (?: [ . ] | ~ [ / ] | [ / \\ ] | [ a - z A - Z ] : ) /
20
20
const isPosixFile = / ^ (?: [ . ] | ~ [ / ] | [ / ] | [ a - z A - Z ] : ) /
Original file line number Diff line number Diff line change @@ -823,3 +823,40 @@ t.test('error message', t => {
823
823
824
824
t . end ( )
825
825
} )
826
+
827
+ t . test ( 'tarball regex should only match literal dots' , t => {
828
+ // Valid tarball extensions - should match
829
+ t . has ( normalizePaths ( npa ( '/path/to/package.tar.gz' ) ) , {
830
+ type : 'file' ,
831
+ name : null ,
832
+ } , '.tar.gz should match as file' )
833
+
834
+ t . has ( normalizePaths ( npa ( '/path/to/package.tgz' ) ) , {
835
+ type : 'file' ,
836
+ name : null ,
837
+ } , '.tgz should match as file' )
838
+
839
+ t . has ( normalizePaths ( npa ( '/path/to/package.tar' ) ) , {
840
+ type : 'file' ,
841
+ name : null ,
842
+ } , '.tar should match as file' )
843
+
844
+ // Invalid patterns with non-dot characters - should NOT match as file
845
+ // These should be treated as directories, not files
846
+ t . has ( normalizePaths ( npa ( '/path/to/package.tarXgz' ) ) , {
847
+ type : 'directory' ,
848
+ name : null ,
849
+ } , '.tarXgz should NOT match as file (X is not a dot)' )
850
+
851
+ t . has ( normalizePaths ( npa ( '/path/to/package.tar_gz' ) ) , {
852
+ type : 'directory' ,
853
+ name : null ,
854
+ } , '.tar_gz should NOT match as file (underscore is not a dot)' )
855
+
856
+ t . has ( normalizePaths ( npa ( './package.tar gz' ) ) , {
857
+ type : 'directory' ,
858
+ name : null ,
859
+ } , '.tar gz should NOT match as file (space is not a dot)' )
860
+
861
+ t . end ( )
862
+ } )
You can’t perform that action at this time.
0 commit comments