@@ -124,6 +124,9 @@ function readRecursive(componentPath) {
124124 componentPath = componentPath . substring ( 0 , ( componentPath . length - 1 ) )
125125 }
126126 const pathicles = componentPath . split ( '\/' ) ;
127+ if ( pathicles [ 0 ] == '' ) {
128+ pathicles . shift ( )
129+ }
127130 const componentName = pathicles . pop ( ) ;
128131 const componentDirectory = pathicles . join ( '/' ) ;
129132
@@ -222,8 +225,10 @@ app.whenReady().then(() => {
222225
223226 let pathicles = componentPath . split ( '\/' ) ;
224227 let componentName = pathicles . pop ( ) ;
228+ if ( pathicles [ 0 ] == '' ) {
229+ pathicles . shift ( )
230+ }
225231 let componentDirectory = pathicles . join ( '/' ) ;
226- pathicles . shift ( ) ;
227232
228233 if ( pathicles [ 0 ] === "api" ) {
229234 pathicles . shift ( ) ;
@@ -290,12 +295,12 @@ app.whenReady().then(() => {
290295 // headers: { 'content-type': 'text/html' }
291296 } )
292297 } else {
293- var target = __dirname + '/simplycode' + componentDirectory + '\/' + componentName ;
298+ var target = __dirname + '/simplycode/ ' + componentDirectory + '\/' + componentName ;
294299 if ( fs . existsSync ( target ) ) {
295300 if ( fs . lstatSync ( target ) . isDirectory ( ) ) {
296301 // Do the recursive read thing;
297302 } else {
298- const filestuff = fs . readFileSync ( __dirname + '/simplycode' + componentDirectory + '\/' + componentName )
303+ const filestuff = fs . readFileSync ( __dirname + '/simplycode/ ' + componentDirectory + '\/' + componentName )
299304 return new Response ( filestuff , {
300305 // headers: { 'content-type': 'text/html' }
301306 } )
@@ -323,7 +328,6 @@ app.whenReady().then(() => {
323328 if ( pathicles [ 0 ] == '' ) {
324329 pathicles . shift ( )
325330 }
326-
327331 let componentDirectory = pathicles . join ( '/' ) ;
328332
329333 switch ( request . method ) {
@@ -361,20 +365,26 @@ app.whenReady().then(() => {
361365
362366 } else {
363367 var target = dataDir + componentDirectory + '\/' + componentName ;
368+ let headers = { } ;
369+ if ( componentName . match ( / \. s v g $ / ) ) {
370+ headers = {
371+ 'content-type' : 'image/svg+xml'
372+ }
373+ }
364374 if ( fs . existsSync ( target ) ) {
365375 const filestuff = fs . readFileSync ( target )
366376 return new Response ( filestuff , {
367- // headers: { 'content-type': 'text/html' }
377+ headers : headers
368378 } )
369379 } else {
370380 if (
371381 ( componentPath . indexOf ( "/js/simply" ) === 0 ) ||
372382 ( componentPath . indexOf ( "/simply" ) === 0 ) ||
373383 ( componentPath . indexOf ( "/hope" ) === 0 )
374384 ) {
375- const filestuff = fs . readFileSync ( __dirname + '/simplycode' + componentDirectory + '\/' + componentName )
385+ const filestuff = fs . readFileSync ( __dirname + '/simplycode/ ' + componentDirectory + '\/' + componentName )
376386 return new Response ( filestuff , {
377- // headers: { 'content-type': 'text/html' }
387+ headers : headers
378388 } )
379389 }
380390 return new Response ( "Not found" , { "status" : 404 } )
0 commit comments