Permalink
Browse files

Don't crash and burn on bad URLs

We now display a super-lame error message instead.
  • Loading branch information...
1 parent df957de commit 893fae1b954ff286d444b333861dc607d68910f4 @aroben committed Apr 16, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 lowercaseme.js
View
@@ -8,6 +8,17 @@ var proxy = new HTTPProxy.RoutingProxy();
HTTP.createServer(function(request, response) {
var innerURL = request.url.substr(1);
var parsedURL = URL.parse(innerURL);
+ if (!parsedURL.hostname) {
+ var body = 'Invalid URL ' + innerURL;
+ response.writeHead(400, {
+ 'Content-Length': body.length,
+ 'Content-Type': 'text/plain'
+ });
+ response.write(body);
+ response.end();
+ return;
+ }
+
request.url = innerURL.toLowerCase();
proxy.proxyRequest(request, response, {

0 comments on commit 893fae1

Please sign in to comment.