Permalink
Browse files

404’ing on unknown ID

  • Loading branch information...
1 parent 1c2d584 commit ddfcc41111bf3957b1d02be272ce04a904badc98 @ELLIOTTCABLE committed Nov 14, 2009
Showing with 13 additions and 7 deletions.
  1. +13 −7 server.js
View
@@ -39,13 +39,19 @@ redis.create_client(function (redis) {
var id = serverRequest.uri.path.slice(1);
redis.get(id, function (username) {
- if (serverRequest.uri.full.indexOf("?") !== -1) {
- var status = 200 } else { var status = 301 };
-
- serverResponse.sendHeader(status, {"Content-Type": "text/plain",
- "Location": "http://"+twitterHost+"/"+username+"/status/"+id});
- serverResponse.sendBody("http://"+twitterHost+"/"+username+"/status/"+id+"\n");
- serverResponse.finish();
+ if (username !== null) {
+ if (serverRequest.uri.full.indexOf("?") !== -1) {
+ var status = 200 } else { var status = 301 };
+
+ serverResponse.sendHeader(status, {"Content-Type": "text/plain",
+ "Location": "http://"+twitterHost+"/"+username+"/status/"+id});
+ serverResponse.sendBody("http://"+twitterHost+"/"+username+"/status/"+id+"\n");
+ serverResponse.finish();
+ } else {
+ serverResponse.sendHeader(404, {"Content-Type": "text/plain"});
+ serverResponse.sendBody("ID not stored!\n");
+ serverResponse.finish();
+ };
});
};
}).listen(49905);

0 comments on commit ddfcc41

Please sign in to comment.