aboutsummaryrefslogtreecommitdiffstats
path: root/lib/nodeserver/server.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nodeserver/server.js')
-rw-r--r--lib/nodeserver/server.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/nodeserver/server.js b/lib/nodeserver/server.js
index f91f6afa..bcaed299 100644
--- a/lib/nodeserver/server.js
+++ b/lib/nodeserver/server.js
@@ -84,12 +84,14 @@ StaticServlet.MimeMap = {
StaticServlet.prototype.handleRequest = function(req, res) {
var self = this;
- var path = ('./' + req.url.pathname).replace('//','/');
+ var path = ('./' + req.url.pathname).replace('//','/').replace(/%(..)/, function(match, hex){
+ return String.fromCharCode(parseInt(hex, 16));
+ });
var parts = path.split('/');
if (parts[parts.length-1].charAt(0) === '.')
return self.sendForbidden_(req, res, path);
fs.stat(path, function(err, stat) {
- if (err)
+ if (err)
return self.sendMissing_(req, res, path);
if (stat.isDirectory())
return self.sendDirectory_(req, res, path);
@@ -118,8 +120,8 @@ StaticServlet.prototype.sendMissing_ = function(req, res, path) {
res.write('<title>404 Not Found</title>\n');
res.write('<h1>Not Found</h1>');
res.write(
- '<p>The requested URL ' +
- escapeHtml(path) +
+ '<p>The requested URL ' +
+ escapeHtml(path) +
' was not found on this server.</p>'
);
res.end();
@@ -135,7 +137,7 @@ StaticServlet.prototype.sendForbidden_ = function(req, res, path) {
res.write('<title>403 Forbidden</title>\n');
res.write('<h1>Forbidden</h1>');
res.write(
- '<p>You do not have permission to access ' +
+ '<p>You do not have permission to access ' +
escapeHtml(path) + ' on this server.</p>'
);
res.end();
@@ -151,8 +153,8 @@ StaticServlet.prototype.sendRedirect_ = function(req, res, redirectUrl) {
res.write('<title>301 Moved Permanently</title>\n');
res.write('<h1>Moved Permanently</h1>');
res.write(
- '<p>The document has moved <a href="' +
- redirectUrl +
+ '<p>The document has moved <a href="' +
+ redirectUrl +
'">here</a>.</p>'
);
res.end();
@@ -187,7 +189,7 @@ StaticServlet.prototype.sendDirectory_ = function(req, res, path) {
return self.sendRedirect_(req, res, redirectUrl);
}
fs.readdir(path, function(err, files) {
- if (err)
+ if (err)
return self.sendError_(req, res, error);
if (!files.length)
@@ -235,5 +237,5 @@ StaticServlet.prototype.writeDirectoryIndex_ = function(req, res, path, files) {
res.end();
};
-// Must be last,
+// Must be last,
main(process.argv);