public static String extractPartsFromURIPattern(String pattern) {
      // Sanitize pattern as it may contains query params expressed using '{{}}'.
      if (pattern.contains("?")) {
         pattern = pattern.substring(0, pattern.indexOf('?'));
      }
      // and as it may contains variables using '{{}}'.
      if (pattern.contains("{{") && pattern.contains("}}")) {
         pattern = pattern.replace("{{", "");
         pattern = pattern.replace("}}", "");
      }
      // and as it may contains $ signs with forms like '/items/$count'.
      if (pattern.contains("$")) {
         pattern = pattern.replace("$", "");
      }

      // Build a pattern for extracting parts from pattern.
      String partsPattern = null;
      if (pattern.contains("/{")) {
         partsPattern = pattern.replaceAll(CURLY_PART_PATTERN, CURLY_PART_EXTRACTION_PATTERN);
      } else if (pattern.contains("/:")) {
         // We should add a leading / to avoid getting port number ;-)
         partsPattern = pattern.replaceAll("(/:[^:^/]+)", "\\/:(.+)");
      }
      return buildPartsDispatchRule(pattern, partsPattern);
   }
@Test
   void testExtractPartsFromURIPattern() {
      // Check with single URI pattern.
      String operationName = "/deployment/byComponent/{component}/{version}?{{param}}";

      String dispatchCriteria = DispatchCriteriaHelper.extractPartsFromURIPattern(operationName);
      assertEquals("component && version", dispatchCriteria);

      // Check with swagger/postman syntax.
      operationName = "/deployment/byComponent/:component/:version?{{param}}";

      dispatchCriteria = DispatchCriteriaHelper.extractPartsFromURIPattern(operationName);
      assertEquals("component && version", dispatchCriteria);

      // Check with extra path containing special character.
      operationName = "/deployment/byComponent/{component}/{version}/$count";

      dispatchCriteria = DispatchCriteriaHelper.extractPartsFromURIPattern(operationName);
      assertEquals("component && version", dispatchCriteria);
   }