@Test public void noPath() throws Exception { String relativeUri = UriUtil.getRelativeUri("http: assertEquals("/", relativeUri); }
public static String getRelativeUri(String completeUri) { int offset = 0; if (completeUri.startsWith("http: offset = 7; } if (completeUri.startsWith("https: offset = 8; } if (completeUri.startsWith("ws: offset = 5; } if (completeUri.startsWith("wss: offset = 6; } int slashIndex = completeUri.indexOf("/", offset); int paramIndex = completeUri.indexOf("?", offset); if (paramIndex != -1 && paramIndex < slashIndex) { return "/" + completeUri.substring(paramIndex); } if (slashIndex != -1) { return completeUri.substring(slashIndex); } if (paramIndex != -1) { return "/" + completeUri.substring(paramIndex); } return "/"; }
UriUtil { public static String getRelativeUri(String completeUri) { int offset = 0; if (completeUri.startsWith("http: offset = 7; } if (completeUri.startsWith("https: offset = 8; } if (completeUri.startsWith("ws: offset = 5; } if (completeUri.startsWith("wss: offset = 6; } int slashIndex = completeUri.indexOf("/", offset); int paramIndex = completeUri.indexOf("?", offset); if (paramIndex != -1 && paramIndex < slashIndex) { return "/" + completeUri.substring(paramIndex); } if (slashIndex != -1) { return completeUri.substring(slashIndex); } if (paramIndex != -1) { return "/" + completeUri.substring(paramIndex); } return "/"; } }
UriUtil { public static String getRelativeUri(String completeUri) { int offset = 0; if (completeUri.startsWith("http: offset = 7; } if (completeUri.startsWith("https: offset = 8; } if (completeUri.startsWith("ws: offset = 5; } if (completeUri.startsWith("wss: offset = 6; } int slashIndex = completeUri.indexOf("/", offset); int paramIndex = completeUri.indexOf("?", offset); if (paramIndex != -1 && paramIndex < slashIndex) { return "/" + completeUri.substring(paramIndex); } if (slashIndex != -1) { return completeUri.substring(slashIndex); } if (paramIndex != -1) { return "/" + completeUri.substring(paramIndex); } return "/"; }  }
UriUtil { public static String getRelativeUri(String completeUri) { int offset = 0; if (completeUri.startsWith("http: offset = 7; } if (completeUri.startsWith("https: offset = 8; } if (completeUri.startsWith("ws: offset = 5; } if (completeUri.startsWith("wss: offset = 6; } int slashIndex = completeUri.indexOf("/", offset); int paramIndex = completeUri.indexOf("?", offset); if (paramIndex != -1 && paramIndex < slashIndex) { return "/" + completeUri.substring(paramIndex); } if (slashIndex != -1) { return completeUri.substring(slashIndex); } if (paramIndex != -1) { return "/" + completeUri.substring(paramIndex); } return "/"; }  static String getUriWithParameters(String uri, List<Param> parameters); static String getRelativeUri(String completeUri); }
UriUtil { public static String getRelativeUri(String completeUri) { int offset = 0; if (completeUri.startsWith("http: offset = 7; } if (completeUri.startsWith("https: offset = 8; } if (completeUri.startsWith("ws: offset = 5; } if (completeUri.startsWith("wss: offset = 6; } int slashIndex = completeUri.indexOf("/", offset); int paramIndex = completeUri.indexOf("?", offset); if (paramIndex != -1 && paramIndex < slashIndex) { return "/" + completeUri.substring(paramIndex); } if (slashIndex != -1) { return completeUri.substring(slashIndex); } if (paramIndex != -1) { return "/" + completeUri.substring(paramIndex); } return "/"; }  static String getUriWithParameters(String uri, List<Param> parameters); static String getRelativeUri(String completeUri);  }