@@ -11,6 +11,9 @@ const store: Record<string, string> = {
1111 'static-no-root/plain.abcdef.txt' : 'That is plain.txt' ,
1212 'assets/static/options/foo.abcdef.txt' : 'With options' ,
1313 'assets/.static/plain.abcdef.txt' : 'In the dot' ,
14+ 'assets/static/video/morning-routine.abcdef.m3u8' : 'Good morning' ,
15+ 'assets/static/video/morning-routine1.abcdef.ts' : 'Good' ,
16+ 'assets/static/video/introduction.abcdef.mp4' : 'Let me introduce myself' ,
1417}
1518const manifest = JSON . stringify ( {
1619 'assets/static/plain.txt' : 'assets/static/plain.abcdef.txt' ,
@@ -123,6 +126,37 @@ describe('With `file` options', () => {
123126 } )
124127} )
125128
129+ describe ( 'With `mimes` options' , ( ) => {
130+ const mimes = {
131+ m3u8 : 'application/vnd.apple.mpegurl' ,
132+ ts : 'video/mp2t' ,
133+ }
134+ const manifest = {
135+ 'assets/static/video/morning-routine.m3u8' : 'assets/static/video/morning-routine.abcdef.m3u8' ,
136+ 'assets/static/video/morning-routine1.ts' : 'assets/static/video/morning-routine1.abcdef.ts' ,
137+ 'assets/static/video/introduction.mp4' : 'assets/static/video/introduction.abcdef.mp4' ,
138+ }
139+
140+ const app = new Hono ( )
141+ app . use ( '/static/*' , serveStatic ( { root : './assets' , mimes, manifest } ) )
142+
143+ it ( 'Should return content-type of m3u8' , async ( ) => {
144+ const res = await app . request ( 'http://localhost/static/video/morning-routine.m3u8' )
145+ expect ( res . status ) . toBe ( 200 )
146+ expect ( res . headers . get ( 'Content-Type' ) ) . toBe ( 'application/vnd.apple.mpegurl' )
147+ } )
148+ it ( 'Should return content-type of ts' , async ( ) => {
149+ const res = await app . request ( 'http://localhost/static/video/morning-routine1.ts' )
150+ expect ( res . status ) . toBe ( 200 )
151+ expect ( res . headers . get ( 'Content-Type' ) ) . toBe ( 'video/mp2t' )
152+ } )
153+ it ( 'Should return content-type of default on Hono' , async ( ) => {
154+ const res = await app . request ( 'http://localhost/static/video/introduction.mp4' )
155+ expect ( res . status ) . toBe ( 200 )
156+ expect ( res . headers . get ( 'Content-Type' ) ) . toBe ( 'video/mp4' )
157+ } )
158+ } )
159+
126160describe ( 'With middleware' , ( ) => {
127161 const app = new Hono ( )
128162 const md1 = async ( c : Context , next : Next ) => {
0 commit comments