
var path = require('path');
var url = require('url');
var urlize = require('nurlize');

var join = path.join;
var normalize = path.normalize;

function isRelative (u) {
  return !u || (u && u.indexOf && u.indexOf('.') === 0);
}

function isAbsolutePath (u) {
  return !u || (u && u.indexOf && u.indexOf('/') === 0);
}

module.exports = function configure (opts, server) {
  // console.log("URLIZE", server.url);
  function getScheme(u) {
    var parts = u.split('//');
    if (parts.length > 1) {
      return [parts[0], parts.slice(1)];
    }
    return;
  }

  return function middleware (req, res, next) {
    var init = urlize.valid(server.url);
    var host = req.headers.host || init[1];
    // XXX: revisit
    var scheme = opts.scheme || init[0];
    if (req.headers['hakken-service']) {
      scheme = 'hakken://';
      host = req.headers['hakken-service'] || opts.host;
    }
    req.urlize = urlize(scheme, host, req.path( )).urlize;
    next( );
  };
};

@@ -2,564 +2,130 @@
 var 
-path = require('path');%0Avar url = require('url');%0Avar urlize = require('nurlize');%0A%0Avar join = path.join;%0Avar normalize = path.normalize;%0A%0Afunction isRelative (u) %7B%0A  return !u %7C%7C (u && u.indexOf && u.indexOf('.') === 0);%0A%7D%0A%0Afunction isAbsolutePath (u) %7B%0A  return !u %7C%7C (u && u.indexOf && u.indexOf('/') === 0);%0A%7D%0A%0Amodule.exports = function configure (opts, server) %7B%0A  // console.log(%22URLIZE%22, server.url);%0A  function getScheme(u) %7B%0A    var parts = u.split('//');%0A    if (parts.length %3E 1) %7B%0A      return %5Bparts%5B0%5D, parts.slice(1)%5D;%0A    %7D%0A    return;%0A  %7D%0A
+urlize = require('nurlize');%0A%0Amodule.exports = function configure (opts, server) %7B%0A  // console.log(%22URLIZE%22, server.url);
 %0A  r

remove dead urlize code