Skip to content

Commit

Permalink
Better output for regular files
Browse files Browse the repository at this point in the history
  • Loading branch information
humphd committed Apr 4, 2014
1 parent bce60c2 commit 5f2d4d9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function(Filer, Async, Log, Content) {
},

/**
* Send the raw file
* Send the raw file, making it somewhat more readable
*/
handleFile: function(path, fs) {
fs.readFile(path, 'utf8', function(err, data) {
Expand All @@ -353,7 +353,16 @@ function(Filer, Async, Log, Content) {
this.handle404(path);
return;
}
_writeMarkup(data);

// Escape the file a bit for inclusing in <pre>...</pre>
data = data.replace(/\</gm, '&lt;')
.replace(/\>/gm, '&gt;')
.replace(/&/gm, '&amp;');

var syntheticDoc = '<!DOCTYPE html>' +
'<html><head></head>' +
'<body><pre>' + data + '</pre></body></html>';
_writeMarkup(syntheticDoc);
});
},

Expand Down

0 comments on commit 5f2d4d9

Please sign in to comment.