@@ -210,17 +210,15 @@ export const staticPlugin = async <Prefix extends string = '/prefix'>(
210210 }
211211 } )
212212
213+ const assetsDir = assets [ 0 ] === sep ? assets : resolve ( ) + sep + assets
214+
213215 if (
214216 alwaysStatic ||
215217 ( process . env . ENV === 'production' && files . length <= staticLimit )
216218 )
217- for ( let i = 0 ; i < files . length ; i ++ ) {
218- const filePath = files [ i ]
219+ for ( const filePath of files ) {
219220 if ( ! filePath || shouldIgnore ( filePath ) ) continue
220-
221- let fileName = filePath
222- . replace ( resolve ( ) , '' )
223- . replace ( `${ assets } ${ sep } ` , '' )
221+ let fileName = filePath . replace ( assetsDir , '' )
224222
225223 if ( noExtension ) {
226224 const temp = fileName . split ( '.' )
@@ -263,7 +261,7 @@ export const staticPlugin = async <Prefix extends string = '/prefix'>(
263261
264262 if ( indexHTML && pathName . endsWith ( '/index.html' ) )
265263 app . get (
266- join ( prefix , pathName . replace ( '/index.html' , '' ) ) ,
264+ pathName . replace ( '/index.html' , '' ) ,
267265 noCache
268266 ? new Response ( file , {
269267 headers
@@ -316,6 +314,9 @@ export const staticPlugin = async <Prefix extends string = '/prefix'>(
316314 statCache . set ( path , status )
317315 }
318316
317+ if ( ! indexHTML && status . isDirectory ( ) )
318+ throw new NotFoundError ( )
319+
319320 let file =
320321 fileCache . get < ReturnType < ( typeof Bun ) [ 'file' ] > > (
321322 path
0 commit comments