code: function removeDotSegments(input) {
  			var output = [];
  			input.replace(/^(\.\.?(\/|$))+/, '')
  				.replace(/\/(\.(\/|$))+/g, '/')
  				.replace(/\/\.\.$/, '/../')
  				.replace(/\/?[^\/]*/g, function (p) {
  					if (p === '/..') {
  						output.pop();
  					} else {
  						output.push(p);
  					}
  				});
  			return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
  		}
docs: RFC 3986