code: function _removeDotSegments(path, hasAuthority) {
    var rval = '';
  
    if(path.indexOf('/') === 0) {
      rval = '/';
    }
  
    // RFC 3986 5.2.4 (reworked)
    var input = path.split('/');
    var output = [];
    while(input.length > 0) {
      if(input[0] === '.' || (input[0] === '' && input.length > 1)) {
        input.shift();
        continue;
      }
      if(input[0] === '..') {
        input.shift();
        if(hasAuthority ||
          (output.length > 0 && output[output.length - 1] !== '..')) {
          output.pop();
        }
        // leading relative URL '..'
        else {
          output.push('..');
        }
        continue;
      }
      output.push(input.shift());
    }
  
    return rval + output.join('/');
  }
docs: Removes dot segments from a URL path.
  
  @param path the path to remove dot segments from.
  @param hasAuthority true if the URL has an authority, false if not.