@Test public void testPathJoin2() { assertEquals(RefUtils.buildUrl("http: assertEquals(RefUtils.buildUrl("http: assertEquals(RefUtils.buildUrl("http: assertEquals(RefUtils.buildUrl("http: assertEquals(RefUtils.buildUrl("http: assertEquals(RefUtils.buildUrl("http: assertEquals(RefUtils.buildUrl("http: assertEquals(RefUtils.buildUrl("http: }
public static String buildUrl(String rootPath, String relativePath) { String[] rootPathParts = rootPath.split("/"); String [] relPathParts = relativePath.split("/"); if(rootPath == null || relativePath == null) { return null; } int trimRoot = 0; int trimRel = 0; if(!"".equals(rootPathParts[rootPathParts.length - 1])) { trimRoot = 1; } if("".equals(relPathParts[0])) { trimRel = 1; trimRoot = rootPathParts.length-3; } for(int i = 0; i < rootPathParts.length; i++) { if("".equals(rootPathParts[i])) { trimRel += 1; } else { break; } } for(int i = 0; i < relPathParts.length; i ++) { if(".".equals(relPathParts[i])) { trimRel += 1; } else if ("..".equals(relPathParts[i])) { trimRel += 1; trimRoot += 1; } } String [] outputParts = new String[rootPathParts.length + relPathParts.length - trimRoot - trimRel]; System.arraycopy(rootPathParts, 0, outputParts, 0, rootPathParts.length - trimRoot); System.arraycopy(relPathParts, trimRel, outputParts, rootPathParts.length - trimRoot, relPathParts.length - trimRel); return StringUtils.join(outputParts, "/"); }
RefUtils { public static String buildUrl(String rootPath, String relativePath) { String[] rootPathParts = rootPath.split("/"); String [] relPathParts = relativePath.split("/"); if(rootPath == null || relativePath == null) { return null; } int trimRoot = 0; int trimRel = 0; if(!"".equals(rootPathParts[rootPathParts.length - 1])) { trimRoot = 1; } if("".equals(relPathParts[0])) { trimRel = 1; trimRoot = rootPathParts.length-3; } for(int i = 0; i < rootPathParts.length; i++) { if("".equals(rootPathParts[i])) { trimRel += 1; } else { break; } } for(int i = 0; i < relPathParts.length; i ++) { if(".".equals(relPathParts[i])) { trimRel += 1; } else if ("..".equals(relPathParts[i])) { trimRel += 1; trimRoot += 1; } } String [] outputParts = new String[rootPathParts.length + relPathParts.length - trimRoot - trimRel]; System.arraycopy(rootPathParts, 0, outputParts, 0, rootPathParts.length - trimRoot); System.arraycopy(relPathParts, trimRel, outputParts, rootPathParts.length - trimRoot, relPathParts.length - trimRel); return StringUtils.join(outputParts, "/"); } }
RefUtils { public static String buildUrl(String rootPath, String relativePath) { String[] rootPathParts = rootPath.split("/"); String [] relPathParts = relativePath.split("/"); if(rootPath == null || relativePath == null) { return null; } int trimRoot = 0; int trimRel = 0; if(!"".equals(rootPathParts[rootPathParts.length - 1])) { trimRoot = 1; } if("".equals(relPathParts[0])) { trimRel = 1; trimRoot = rootPathParts.length-3; } for(int i = 0; i < rootPathParts.length; i++) { if("".equals(rootPathParts[i])) { trimRel += 1; } else { break; } } for(int i = 0; i < relPathParts.length; i ++) { if(".".equals(relPathParts[i])) { trimRel += 1; } else if ("..".equals(relPathParts[i])) { trimRel += 1; trimRoot += 1; } } String [] outputParts = new String[rootPathParts.length + relPathParts.length - trimRoot - trimRel]; System.arraycopy(rootPathParts, 0, outputParts, 0, rootPathParts.length - trimRoot); System.arraycopy(relPathParts, trimRel, outputParts, rootPathParts.length - trimRoot, relPathParts.length - trimRel); return StringUtils.join(outputParts, "/"); } private  RefUtils(); }
RefUtils { public static String buildUrl(String rootPath, String relativePath) { String[] rootPathParts = rootPath.split("/"); String [] relPathParts = relativePath.split("/"); if(rootPath == null || relativePath == null) { return null; } int trimRoot = 0; int trimRel = 0; if(!"".equals(rootPathParts[rootPathParts.length - 1])) { trimRoot = 1; } if("".equals(relPathParts[0])) { trimRel = 1; trimRoot = rootPathParts.length-3; } for(int i = 0; i < rootPathParts.length; i++) { if("".equals(rootPathParts[i])) { trimRel += 1; } else { break; } } for(int i = 0; i < relPathParts.length; i ++) { if(".".equals(relPathParts[i])) { trimRel += 1; } else if ("..".equals(relPathParts[i])) { trimRel += 1; trimRoot += 1; } } String [] outputParts = new String[rootPathParts.length + relPathParts.length - trimRoot - trimRel]; System.arraycopy(rootPathParts, 0, outputParts, 0, rootPathParts.length - trimRoot); System.arraycopy(relPathParts, trimRel, outputParts, rootPathParts.length - trimRoot, relPathParts.length - trimRel); return StringUtils.join(outputParts, "/"); } private  RefUtils(); static String computeDefinitionName(String ref); static Optional<String> getExternalPath(String ref); static boolean isAnExternalRefFormat(RefFormat refFormat); static RefFormat computeRefFormat(String ref); static String mungedRef(String refString); static String readExternalUrlRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                            String rootPath); static String readExternalClasspathRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                                  String rootPath); static String buildUrl(String rootPath, String relativePath); static String readExternalRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                         Path parentDirectory); }
RefUtils { public static String buildUrl(String rootPath, String relativePath) { String[] rootPathParts = rootPath.split("/"); String [] relPathParts = relativePath.split("/"); if(rootPath == null || relativePath == null) { return null; } int trimRoot = 0; int trimRel = 0; if(!"".equals(rootPathParts[rootPathParts.length - 1])) { trimRoot = 1; } if("".equals(relPathParts[0])) { trimRel = 1; trimRoot = rootPathParts.length-3; } for(int i = 0; i < rootPathParts.length; i++) { if("".equals(rootPathParts[i])) { trimRel += 1; } else { break; } } for(int i = 0; i < relPathParts.length; i ++) { if(".".equals(relPathParts[i])) { trimRel += 1; } else if ("..".equals(relPathParts[i])) { trimRel += 1; trimRoot += 1; } } String [] outputParts = new String[rootPathParts.length + relPathParts.length - trimRoot - trimRel]; System.arraycopy(rootPathParts, 0, outputParts, 0, rootPathParts.length - trimRoot); System.arraycopy(relPathParts, trimRel, outputParts, rootPathParts.length - trimRoot, relPathParts.length - trimRel); return StringUtils.join(outputParts, "/"); } private  RefUtils(); static String computeDefinitionName(String ref); static Optional<String> getExternalPath(String ref); static boolean isAnExternalRefFormat(RefFormat refFormat); static RefFormat computeRefFormat(String ref); static String mungedRef(String refString); static String readExternalUrlRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                            String rootPath); static String readExternalClasspathRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                                  String rootPath); static String buildUrl(String rootPath, String relativePath); static String readExternalRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
                                         Path parentDirectory);  }