@@ -27,15 +27,14 @@ function setContentType(res, path, stat) {
2727 const ext = mPath . extname ( path ) ;
2828 if ( ext . length == 0 ) {
2929 const buffer = mFs . readFileSync ( path ) ;
30- if ( isBinary ( null , buffer ) ) {
31- console . log ( "BINARY: " + path ) ;
30+ const name = mPath . basename ( path ) ;
31+ if ( isInterlispSource ( buffer , name ) {
3232 res . set ( 'Content-Type' , 'application/octet-stream' ) ;
3333 } else if ( isText ( null , buffer ) ) {
34- console . log ( "TEXT: " + path ) ;
3534 res . set ( 'Content-Type' , 'text/plain; charset=UTF-8' ) ;
3635 res . set ( 'X-Content-Type-Options' , 'nosniff' ) ;
37- } else {
38- console . log ( "NEITHER: " + path ) ;
36+ } else {
37+ res . set ( 'Content-Type' , 'application/octet-stream' ) ;
3938 }
4039 } else {
4140 switch ( ext ) {
@@ -57,6 +56,16 @@ function setContentType(res, path, stat) {
5756 }
5857}
5958
59+ // Does buffer contain an Interlisp source file?
60+ function isInterlispSource ( buffer , name ) {
61+ return (
62+ buffer . includes ( "(DEFINE-FILE-INFO" )
63+ && buffer . includes ( name + "COMS" )
64+ ) ;
65+
66+ }
67+
68+
6069filesApp . use ( ( req , res , next ) => {
6170 if ( req . protocol === 'https' || ! config . supportHttps ) next ( ) ;
6271 else res . redirect ( `https://${ req . hostname } :${ config . httpsRedirectPort } ${ req . url } ` ) ;
0 commit comments