@@ -199,35 +199,13 @@ class CoCreateFileSystem {
199199
200200 let contentType = file [ "content-type" ] || "text/html" ;
201201
202- try {
203- if ( typeof src === "string" ) {
204- // Decode the file content based on its MIME type
205- if ( / ^ ( i m a g e | a u d i o | v i d e o | f o n t | a p p l i c a t i o n \/ o c t e t - s t r e a m | a p p l i c a t i o n \/ x - f o n t - t t f | a p p l i c a t i o n \/ x - f o n t - w o f f | a p p l i c a t i o n \/ x - f o n t - w o f f 2 | a p p l i c a t i o n \/ x - f o n t - o p e n t y p e | a p p l i c a t i o n \/ x - f o n t - t r u e t y p e | a p p l i c a t i o n \/ x - f o n t - e o t ) / . test ( contentType ) ) {
206- src = Buffer . from ( src , "base64" ) ;
207- } else if ( / ^ ( a p p l i c a t i o n \/ z i p | a p p l i c a t i o n \/ x - 7 z - c o m p r e s s e d | a p p l i c a t i o n \/ x - r a r - c o m p r e s s e d | a p p l i c a t i o n \/ p d f ) / . test ( contentType ) ) {
208- src = Buffer . from ( src , "binary" ) ;
209- } else {
210- src = Buffer . from ( src , "utf8" ) ;
211- }
212- } else {
213- throw new Error ( "File content is not in a valid format" ) ;
214- }
215- } catch ( err ) {
216- console . error ( "Error decoding file content:" , {
217- message : err . message ,
218- contentType,
219- srcType : typeof src
220- } ) ;
221- let pageNotFound = await getDefaultFile ( "/404.html" ) ;
222- return sendResponse ( pageNotFound . object [ 0 ] . src , 404 , {
223- "Content-Type" : "text/html"
224- } ) ;
225- }
226-
227202 // Remove redundant handling for `src.src` in font file processing
228203 if ( contentType . startsWith ( "font/" ) || / \. ( w o f f 2 ? | t t f | o t f ) $ / i. test ( pathname ) ) {
229204 try {
230205 if ( typeof src === "string" ) {
206+ if ( src . startsWith ( "data:font/" ) ) {
207+ src = src . substring ( src . indexOf ( "," ) + 1 ) ;
208+ }
231209 if ( / ^ ( [ A - Z a - z 0 - 9 + / ] + = { 0 , 2 } ) $ / . test ( src ) ) {
232210 // Decode base64-encoded font data
233211 src = Buffer . from ( src , "base64" ) ;
@@ -275,10 +253,10 @@ class CoCreateFileSystem {
275253 contentType === "text/xml" ||
276254 contentType === "application/xml"
277255 ) {
278- const protocol = "https://" ; // || req.headers['x-forwarded-proto'] || req.protocol;
256+ const protocol = "https://" ;
279257 src = src . replaceAll ( "{{$host}}" , `${ protocol } ${ hostname } ` ) ;
280- } else {
281- // Log unknown file types
258+ } else if ( contentType !== "text/javascript" || contentType === "text/css" ) {
259+
282260 console . warn ( `Unknown content type: ${ contentType } ` ) ;
283261 }
284262
0 commit comments