Permalink
Browse files

Changed default dir support in fileserver

  • Loading branch information...
1 parent 9a63f74 commit aa46405143ec184c4392384d8e62861ad7978a63 @tsjamm tsjamm committed Mar 12, 2013
Showing with 6 additions and 4 deletions.
  1. +6 −4 controllers/fileserver.js
@@ -32,13 +32,15 @@ function serveFile(req,res,defaultDir)
var reqDetails = url.parse(req.url);
logger.write("Request Details: "+JSON.stringify(reqDetails));
var filepath =reqDetails.pathname;
+ filepath = filepath.split('/'+filepath.split('/')[1])[1];
+ logger.write('filepath is '+filepath);
if(defaultDir==null ||defaultDir==undefined)
defaultDir='/public';
- if(filepath=='/')
- filepath = defaultDir+'/index.html';
+ if(filepath == '/' || filepath == '' || filepath == null || filepath == undefined)
+ filepath = '/index.html';
- //fs.readFile("."+defaultDir+filepath,function(err,data){
- fs.readFile("."+filepath,function(err,data){
+ fs.readFile("./"+defaultDir+filepath,function(err,data){
+ //fs.readFile("."+filepath,function(err,data){
if(err)
{
respond.createResponse(res,404,null,'Requested Resourse is not found on the server. Please Check the URL');

0 comments on commit aa46405

Please sign in to comment.