function encodePath(path) {
  var segments = path.split('/'),
      i = segments.length;

  while (i--) {
    // decode forward slashes to prevent them from being double encoded
    segments[i] = encodeUriSegment(segments[i].replace(/%2F/g, '/'));
  }

  return segments.join('/');
}
function encodePath(path) {
  var segments = path.split('/'),
      i = segments.length;

  while (i--) {
    
    segments[i] = encodeUriSegment(segments[i].replace(/%2F/g, '/'));
  }

  return segments.join('/');
}
function encodePath ( path ) { var segments = path . split ( '/' ) , i = segments . length ; while ( i -- ) { // decode forward slashes to prevent them from being double encoded segments [ i ] = encodeUriSegment ( segments [ i ] . replace ( / %2F / g , '/' ) ) ; } return segments . join ( '/' ) ; }
Encode path using encodeUriSegment, ignoring forward slashes

@param {string} path Path to encode
@returns {string}
Encode path using encodeUriSegment ignoring forward slashes