Skip to content

Commit

Permalink
Changed default dir support in fileserver
Browse files Browse the repository at this point in the history
  • Loading branch information
tsjamm committed Mar 12, 2013
1 parent 9a63f74 commit aa46405
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions controllers/fileserver.js
Expand Up @@ -32,13 +32,15 @@ function serveFile(req,res,defaultDir)
var reqDetails = url.parse(req.url); var reqDetails = url.parse(req.url);
logger.write("Request Details: "+JSON.stringify(reqDetails)); logger.write("Request Details: "+JSON.stringify(reqDetails));
var filepath =reqDetails.pathname; var filepath =reqDetails.pathname;
filepath = filepath.split('/'+filepath.split('/')[1])[1];
logger.write('filepath is '+filepath);
if(defaultDir==null ||defaultDir==undefined) if(defaultDir==null ||defaultDir==undefined)
defaultDir='/public'; defaultDir='/public';
if(filepath=='/') if(filepath == '/' || filepath == '' || filepath == null || filepath == undefined)
filepath = defaultDir+'/index.html'; filepath = '/index.html';


//fs.readFile("."+defaultDir+filepath,function(err,data){ fs.readFile("./"+defaultDir+filepath,function(err,data){
fs.readFile("."+filepath,function(err,data){ //fs.readFile("."+filepath,function(err,data){
if(err) if(err)
{ {
respond.createResponse(res,404,null,'Requested Resourse is not found on the server. Please Check the URL'); respond.createResponse(res,404,null,'Requested Resourse is not found on the server. Please Check the URL');
Expand Down

0 comments on commit aa46405

Please sign in to comment.