code: public static String concatPaths(@Nullable String path1, @Nullable String path2) {
          path2 = path2 == null ? "" : path2;
  
          if (path1 == null || path1.isEmpty() || EMPTY_REQUEST_PATH.equals(path1)) {
              if (path2.isEmpty()) {
                  return EMPTY_REQUEST_PATH;
              }
  
              if (path2.charAt(0) == '/') {
                  return path2; // Most requests will land here.
              }
  
              return new StringBuilder(path2.length() + 1)
                      .append('/').append(path2).toString();
          }
  
          // At this point, we are sure path1 is neither empty nor null.
          if (path2.isEmpty()) {
              // Only path1 is non-empty. No need to concatenate.
              return path1;
          }
  
          if (path1.charAt(path1.length() - 1) == '/') {
              if (path2.charAt(0) == '/') {
                  // path1 ends with '/' and path2 starts with '/'.
                  // Avoid double-slash by stripping the first slash of path2.
                  return new StringBuilder(path1.length() + path2.length() - 1)
                          .append(path1).append(path2, 1, path2.length()).toString();
              }
  
              // path1 ends with '/' and path2 does not start with '/'.
              // Simple concatenation would suffice.
              return new StringBuilder(path1.length() + path2.length())
                      .append(path1).append(path2).toString();
          }
  
          if (path2.charAt(0) == '/') {
              // path1 does not end with '/' and path2 starts with '/'.
              // Simple concatenation would suffice.
              return path1 + path2;
          }
  
          // path1 does not end with '/' and path2 does not start with '/'.
          // Need to insert '/' between path1 and path2.
          return new StringBuilder(path1.length() + path2.length() + 1)
                  .append(path1).append('/').append(path2).toString();
      }
docs: Concatenates two path strings.