title: 400 bad request returning /favicon.ico as req.url in express.
body: <p>I am building a simple microservice which returns the url date parameters as a Json object in unix and natural language. For example if you go to 
  <a href="https://cyber-clock.glitch.me/May%2013,%202015" rel="nofollow noreferrer">https://cyber-clock.glitch.me/May%2013,%202015</a> 
  the app should return: <strong>{"unix":1431475200,"natural":"May 13, 2015"}</strong>, 
  the %20 are spaces, so you can also write 
  <a href="https://cyber-clock.glitch.me/May" rel="nofollow noreferrer">https://cyber-clock.glitch.me/May</a> 13, 2015 
  and the app works. 
  The issue is when I write a double percentage because I am getting a 400 bad request error and the url becomes: <strong>/favicon.ico</strong>, so I cannot apply fixes to url and response as expected, for example: 
  <a href="https://cyber-clock.glitch.me/May%%2013,%202015" rel="nofollow noreferrer">https://cyber-clock.glitch.me/May%%2013,%202015</a></p>
  
  <p>You can check the source code here: <a href="https://github.com/juandata/TimeStampMicroService" rel="nofollow noreferrer">https://github.com/juandata/TimeStampMicroService</a></p>
  
  <p>In line 22 of timeStampMicroService.js I added a console.log where you can see what I mean. Here is the code of that file: </p>
  
  <pre><code>var path = require('path')
  var express = require('express');
  var app = express();
  var fs = require('fs');
  var url = require('url');
  var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
    jsonResp = {},
    readableDate = "";
  function Unix_timestamp(t) {
    var dt = new Date(t * 1000);
    var month = dt.getMonth();
    var day = dt.getDate();
    var year = dt.getFullYear();
    return months[month] + ' ' + day + ', ' + year;
  };  
  app.use(function(req, res, next) {
    console.log(req.url);
    var date = req.url.substr(1);
    var miliseconds = parseInt(date);
    var unixDate = new Date(miliseconds);
    if (unixDate == "Invalid Date") {
      var regExpr = /%20|,/;
      date = date.split(regExpr);
      var date1 = new Date(date[0] + " " + date[1] + "," + date[3]);
      if (date1 == "Invalid Date") {
        jsonResp = {
          "unix": null,
          "natural": null
        };
        res.json(jsonResp);
  
      } else {
        var date2 = date1.getTime();
        var timestamp = Math.floor(date2 / 1000);
        jsonResp = {
          "unix": timestamp,
          "natural": date[0] + " " + date[1] + ", " + date[3]
        };
        res.json(jsonResp);
      }
    } else {
      readableDate = Unix_timestamp(date);
      jsonResp = {
        "unix": miliseconds,
        "natural": readableDate
      };
  
      res.json(jsonResp);
    }
  });
  app.listen(process.env.PORT, function() {
    console.log('Node.js listening ...');
  });
  </code></pre>
  
  <p>Can anyone help me to solve this?</p>