code: public static void ensureEndsWithSlash(StringBuilder str) {
          if (str.length() == 0 || str.charAt(str.length() - 1) != '/') {
              str.append('/');
          }
      }
docs: Given a string builder, this ensures its last character is a forward-slash.
  
  @param str string builder to have a forward-slash character as its last when this method returns