'use strict';

exports = module.exports = { };

// dependencies
//
exports.clone = require('lodash.clone');
exports.merge = require('lodash.merge');

/**
# boil(string path [, object options])
> path normalizer

arguments
- path, type `string`
- options, type `object` holding all extra information

returns
- null for non supported types
- an object with path and url props only

if the `o` object given had a not found prop
**/

var qsRE = new RegExp([
  '\\/?', // urls can end with slash but is optional
  '[?#]', // start of querystring/hash
  '[^!=:]', // exclude ?!, ?= and ?: regex strings
  '[^ ]+'
].join(''), 'g');

exports.boil = function boil(path, o){
  if(typeof path !== 'string'){ return null; }

  o = o || {};
  o.path = path.replace(/[ ]+/, ' ').trim();
  var urls = o.path.match(/(?:^|[ ])\/\S*/g) || [];

  urls.forEach(function(url){
    url = url.trim();
    o.path = o.path.replace(url, url.replace(qsRE, '') || '/');
  });

  if(o.notFound){
    o.url = urls.length > 1 ? urls : urls[0];
    o.notFound = o.path;
  }

  return o;
};

@@ -798,24 +798,21 @@
 ch(/
-(?:%5E%7C%5B %5D)
+%5B%5E%5C/ %5D*
 %5C/%5CS*/
-g
 ) %7C%7C
@@ -851,30 +851,8 @@
 l)%7B%0A
-    url = url.trim();%0A
     

remove unnecessary trimming