@@ -89,7 +89,7 @@ export const staticPlugin = async <Prefix extends string = '/prefix'>(
8989 */
9090 staticLimit ?: number
9191 /**
92- * @default false
92+ * @default false unless `NODE_ENV` is 'production'
9393 *
9494 * Should file always be served statically
9595 */
@@ -216,23 +216,23 @@ export const staticPlugin = async <Prefix extends string = '/prefix'>(
216216 alwaysStatic ||
217217 ( process . env . ENV === 'production' && files . length <= staticLimit )
218218 )
219- for ( const filePath of files ) {
220- if ( ! filePath || shouldIgnore ( filePath ) ) continue
221- let fileName = filePath . replace ( assetsDir , '' )
219+ for ( const absolutePath of files ) {
220+ if ( ! absolutePath || shouldIgnore ( absolutePath ) ) continue
221+ let relativePath = absolutePath . replace ( assetsDir , '' )
222222
223223 if ( noExtension ) {
224- const temp = fileName . split ( '.' )
224+ const temp = relativePath . split ( '.' )
225225 temp . splice ( - 1 )
226226
227- fileName = temp . join ( '.' )
227+ relativePath = temp . join ( '.' )
228228 }
229229
230- const file = Bun . file ( filePath )
230+ const file = Bun . file ( absolutePath )
231231 const etag = await generateETag ( file )
232232
233233 const pathName = isFSSepUnsafe
234- ? prefix + fileName . split ( sep ) . join ( URL_PATH_SEP )
235- : join ( prefix , fileName )
234+ ? prefix + relativePath . split ( sep ) . join ( URL_PATH_SEP )
235+ : join ( prefix , relativePath )
236236
237237 app . get (
238238 pathName ,
@@ -241,7 +241,7 @@ export const staticPlugin = async <Prefix extends string = '/prefix'>(
241241 headers
242242 } )
243243 : async ( { headers : reqHeaders } ) => {
244- if ( await isCached ( reqHeaders , etag , filePath ) ) {
244+ if ( await isCached ( reqHeaders , etag , absolutePath ) ) {
245245 return new Response ( null , {
246246 status : 304 ,
247247 headers
0 commit comments