code: private static String normalize(final String path) {
          final StringBuilder builder = new StringBuilder(path);
  
          int index = 0;
          int colonIndex = -1;
          char current = 0;
          char last;
  
          while ((index > -1) && (index < builder.length())) {
              last = current;
              current = builder.charAt(index);
  
              switch (current) {
                  case '}':
                      if (last == '\\')
                          break;
                      if (colonIndex != -1) {
                          builder.delete(colonIndex, index);
                          index = colonIndex;
                          colonIndex = -1;
                      }
                      break;
                  case ':':
                      if (colonIndex == -1) {
                          colonIndex = index;
                      }
                      break;
              }
  
              if ((index == 0 || index == builder.length() - 1) && current == '/') {
                  builder.deleteCharAt(index);
                  if (index == builder.length()) {
                      // check again for path end
                      index--;
                  }
              } else {
                  index++;
              }
          }
  
          return builder.toString();
      }
docs: Normalizes the given path, i.e. trims leading or trailing forward-slashes and removes path parameter matchers.
  
  @param path The path to normalize
  @return The normalized path