title: node.js - page keeps loading - no errors to investigate
body: <p>this is <code>1.js</code> <br>
  let's run it </p>
  
  <pre><code>node 1.js
  </code></pre>
  
  <p>and then on the web<br>
  execute:  <code>domain.tld/-2</code></p>
  
  <p>it all works perfect. <br>
  i see it loaded <code>2.js</code> and then<br>
  used a function to do the mysql query<br>
  and displays all the results. perfect.</p>
  
  <p>now on the web let's try to
  go to : <code>domain.tld/-3</code></p>
  
  <p><code>1.js</code> tries to load <code>3.js</code><br>
  because the urlpath name is '/-3'<br>
  but there is no '<code>3.js</code>'</p>
  
  <p>i am expecting it to say<br></p>
  
  <pre><code>"page not found'
  </code></pre>
  
  <p><code>node 1.js</code> is not crashing.<br>
  and web browser is still.. '<code>loading..</code>"</p>
  
  <p>here is the 1.js :</p>
  
  <pre><code>var http = require('http');
  var url = require('url');
  var mysql = require('mysql');
  
  var Memcached = require('memcached');
  var memcached = new Memcached('localhost:11211');
  
  var connection = mysql.createConnection({
      host     : '--------------',
      user     : '2',
      password : '-------------',
      database : '1'
  });
  
  connection.connect();
  
  
  var server=http.createServer(function(req,res){
      res.writeHead(200,{'Content-Type': 'text/html; charset=utf-8'});
  var pathname=url.parse(req.url).pathname;
  
  if (pathname.match(/\/-\d{1,2}/)) {
       pathname = pathname.replace('-', '')
  
      try{
      var o = require('/' + pathname + '.js')
      } catch (err){
      var o = '0'
      }
  
      if (o == '0'){
          o = 'page not found'
      }else{
           o.makeQuery(connection, function(err, result){
               if(err) return res.end(err);
           o = result;
               res.end(o)
           });
      }
  
  } else if (pathname.match(/^\/$/)) {
      res.end('welcome to index page');
  } else {
      pathname = pathname.replace('/', 'o');
      res.end('welcome to user profile page');
  }
  
  }).listen(80);
  </code></pre>
  
  <p>although it may not matter.. <br>
  here is the <code>2.js</code> </p>
  
  <pre><code>exports.makeQuery = function(connection, callback) {
  
    var queryString = 'SELECT * FROM 1_accounts order by ac_nu asc limit 5';
  
    connection.query(queryString, function(err,res,fields){
      if (err) {return callback(err)};
  
      bb = JSON.stringify(res);
      callback(null, bb);
    });
  }
  </code></pre>
  
  <p>before i added the following segment to<br>
  1.js it was working fine via web. </p>
  
  <pre><code>if (pathname.match(/\/-\d{1,2}/)) {
  } else if (pathname.match(/^\/$/)) {
  } else {
  }
  </code></pre>
  
  <p>in other words it must have something to do<br>
  with those perhaps. </p>
  
  <p>before i added those lines..<br>
  it would smoothly display:</p>
  
  <pre><code>"page not found"
  </code></pre>