@@ -50,7 +50,7 @@ async function fetchFileContent(
5050 packageName : string ,
5151 version : string ,
5252 filePath : string ,
53- ) : Promise < string > {
53+ ) : Promise < { content : string ; contentType : string | null } > {
5454 const url = `https://cdn.jsdelivr.net/npm/${ packageName } @${ version } /${ filePath } `
5555 const response = await fetch ( url )
5656
@@ -64,6 +64,8 @@ async function fetchFileContent(
6464 } )
6565 }
6666
67+ const contentType = response . headers . get ( 'content-type' )
68+
6769 // Check content-length header if available
6870 const contentLength = response . headers . get ( 'content-length' )
6971 if ( contentLength && parseInt ( contentLength , 10 ) > MAX_FILE_SIZE ) {
@@ -83,7 +85,7 @@ async function fetchFileContent(
8385 } )
8486 }
8587
86- return content
88+ return { content, contentType }
8789}
8890
8991/**
@@ -123,7 +125,7 @@ export default defineCachedEventHandler(
123125 filePath : rawFilePath ,
124126 } )
125127
126- const content = await fetchFileContent ( packageName , version , filePath )
128+ const { content, contentType } = await fetchFileContent ( packageName , version , filePath )
127129 const language = getLanguageFromPath ( filePath )
128130
129131 // For JS/TS files, resolve dependency versions and relative imports for linking
@@ -185,6 +187,7 @@ export default defineCachedEventHandler(
185187 version,
186188 path : filePath ,
187189 language,
190+ contentType,
188191 content,
189192 html,
190193 lines : content . split ( '\n' ) . length ,
0 commit comments