File tree 3 files changed +19
-3
lines changed
vite/src/node/server/middlewares
3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,13 @@ describe('main', () => {
97
97
} )
98
98
99
99
test ( 'denied' , async ( ) => {
100
- expect ( await page . textContent ( '.unsafe-dotenv' ) ) . toBe ( '404' )
100
+ expect ( await page . textContent ( '.unsafe-dotenv' ) ) . toBe ( '403' )
101
+ } )
102
+
103
+ test ( 'denied EnV casing' , async ( ) => {
104
+ // It is 403 in case insensitive system, 404 in others
105
+ const code = await page . textContent ( '.unsafe-dotEnV-casing' )
106
+ expect ( code === '403' || code === '404' ) . toBeTruthy ( )
101
107
} )
102
108
} else {
103
109
test ( 'dummy test to make jest happy' , async ( ) => {
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ <h2>Nested Entry</h2>
45
45
46
46
< h2 > Denied</ h2 >
47
47
< pre class ="unsafe-dotenv "> </ pre >
48
+ < pre class ="unsafe-dotEnV-casing "> </ pre >
48
49
49
50
< script type ="module ">
50
51
import '../../entry'
@@ -202,14 +203,23 @@ <h2>Denied</h2>
202
203
} )
203
204
204
205
// .env, denied by default
205
- fetch ( '/@fs/' + ROOT + '/root/.env' )
206
+ fetch ( '/@fs/' + ROOT + '/root/src/ .env' )
206
207
. then ( ( r ) => {
207
208
text ( '.unsafe-dotenv' , r . status )
208
209
} )
209
210
. catch ( ( e ) => {
210
211
console . error ( e )
211
212
} )
212
213
214
+ // .env, for case insensitive file systems
215
+ fetch ( '/@fs/' + ROOT + '/root/src/.EnV' )
216
+ . then ( ( r ) => {
217
+ text ( '.unsafe-dotEnV-casing' , r . status )
218
+ } )
219
+ . catch ( ( e ) => {
220
+ console . error ( e )
221
+ } )
222
+
213
223
function text ( sel , text ) {
214
224
document . querySelector ( sel ) . textContent = text
215
225
}
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ export function serveRawFsMiddleware(
156
156
}
157
157
}
158
158
159
- const _matchOptions = { matchBase : true }
159
+ const _matchOptions = { matchBase : true , nocase : true }
160
160
161
161
export function isFileServingAllowed (
162
162
url : string ,
You can’t perform that action at this time.
0 commit comments