LibUtils { public static URL generateDirectIpaUrl(String referer, String ipaClassifier, String otaClassifier) throws MalformedURLException { int idx = referer.lastIndexOf("."); if (idx > 0 && idx > referer.length() - 6) { String ipaUrl = referer.substring(0, idx) + ".ipa"; if (!StringUtils.isEmpty(otaClassifier)) { if (!StringUtils.isEmpty(ipaClassifier)) { ipaUrl = replaceLast(ipaUrl, "-" + otaClassifier, "-" + ipaClassifier); } else { ipaUrl = replaceLast(ipaUrl, "-" + otaClassifier, ""); } } else { if (!StringUtils.isEmpty(ipaClassifier)) { ipaUrl = ipaUrl.substring(0, idx) + "-" + ipaClassifier + ".ipa"; } } return new URL(ipaUrl); } else { throw new MalformedURLException("Referer does not end with a file (e.g. .htm): " + referer); } }  static URL buildUrl(String urlPrefix, String urlSuffix); static URL generateDirectIpaUrl(String referer, String ipaClassifier, String otaClassifier); static String replaceLast(String string, String searchString, String replaceString); static String urlEncode(String string); static String urlDecode(String string); static String encode(String string); static String decode(String string); static Map<String, String> buildMap(String... keyValuePairs);  }
@Test public void testGenerateDirectIpaUrl() throws MalformedURLException { assertEquals("http: "http: assertEquals("http: "http: assertEquals("http: "http: String ipaClassifier = "Production-iphoneos"; String otaClassifier = "OTA"; assertEquals("http: "http: assertEquals("http: "http: assertEquals("http: "http: assertEquals( "http: LibUtils.generateDirectIpaUrl( "http: ipaClassifier, otaClassifier).toExternalForm()); try { LibUtils.generateDirectIpaUrl("http: fail("No exception"); } catch(MalformedURLException e) { } }