@@ -100,17 +100,33 @@ describe('validatePath', () => {
100100 const driveLetter = windowsTempDir . split ( ':' ) [ 0 ] ;
101101
102102 test ( 'should handle Windows absolute paths with drive letters' , async ( ) => {
103- const windowsPath = `${ driveLetter } :\\Windows\\Temp\\test\\file.txt` ;
104- const allowedDirs = [ `${ driveLetter } :\\Windows\\Temp` ] ;
103+ const testDir = `${ driveLetter } :\\test_validate_path` ;
104+ await fs . mkdir ( testDir , { recursive : true } ) ;
105+
106+ const windowsPath = `${ driveLetter } :\\test_validate_path\\file.txt` ;
107+ const allowedDirs = [ `${ driveLetter } :\\` ] ;
105108 const validatedPath = await validatePath ( windowsPath , allowedDirs ) ;
106109 expect ( validatedPath ) . toBe ( path . resolve ( windowsPath ) ) ;
107110 } ) ;
108111
109112 test ( 'should handle Windows paths with spaces' , async ( ) => {
110- const spacePath = `${ driveLetter } :\\Program Files\\test\\file.txt` ;
111- const allowedDirs = [ `${ driveLetter } :\\Program Files` ] ;
113+ const testDir = `${ driveLetter } :\\test folder` ;
114+ await fs . mkdir ( testDir , { recursive : true } ) ;
115+
116+ const spacePath = `${ driveLetter } :\\test folder\\file.txt` ;
117+ const allowedDirs = [ `${ driveLetter } :\\` ] ;
112118 const validatedPath = await validatePath ( spacePath , allowedDirs ) ;
113119 expect ( validatedPath ) . toBe ( path . resolve ( spacePath ) ) ;
114120 } ) ;
121+
122+ test ( 'should handle Windows TEMP paths' , async ( ) => {
123+ const testDir = path . join ( windowsTempDir , 'test_validate_path' ) ;
124+ await fs . mkdir ( testDir , { recursive : true } ) ;
125+
126+ const tempPath = path . join ( testDir , 'file.txt' ) ;
127+ const allowedDirs = [ windowsTempDir ] ;
128+ const validatedPath = await validatePath ( tempPath , allowedDirs ) ;
129+ expect ( validatedPath ) . toBe ( path . resolve ( tempPath ) ) ;
130+ } ) ;
115131 }
116132} ) ;
0 commit comments