Permalink
Browse files

Fixed invalid redirect when accessing a directory with a query string.

  • Loading branch information...
1 parent fe07677 commit 288afdd34141a0ea543ecd923af4e651470c8de2 @thedjinn thedjinn committed Aug 20, 2010
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/antinode.js
View
@@ -145,12 +145,14 @@ function serve_static_file(path, req, resp) {
return file_not_found();
}
if (stats.isDirectory()) {
- if (req.url.match(/\/$/)) {
+ var parsed_url = uri.parse(req.url);
+ if (parsed_url.pathname.match(/\/$/)) {
return serve_static_file(pathlib.join(path, "index.html"), req, resp);
}
else {
var redirect_host = req.headers.host ? ('http://' + req.headers['host']) : '';
- return redirect_302_found(redirect_host + req.url + '/');
+ var redirect_path = parsed_url.pathname + "/" + (parsed_url.search || "");
+ return redirect_302_found(redirect_host + redirect_path);
}
}
if (!stats.isFile()) {

0 comments on commit 288afdd

Please sign in to comment.