mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 10:41:06 +01:00
added javadoc and unit test
This commit is contained in:
@@ -356,9 +356,7 @@ public class Repository extends BasicPropertiesAware implements ModelObject, Per
|
||||
* @since 1.17
|
||||
*/
|
||||
public String createUrl(String baseUrl) {
|
||||
String url = HttpUtil.append(baseUrl, type);
|
||||
|
||||
return HttpUtil.concatenate(url, namespace, name);
|
||||
return HttpUtil.concatenate(baseUrl, type, namespace, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -248,6 +248,14 @@ public final class HttpUtil
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Joins all path elements together separated by {@code {@link #SEPARATOR_PATH}}.
|
||||
*
|
||||
* @param pathElements path elements
|
||||
*
|
||||
* @return concatenated path
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public static String concatenate(String... pathElements) {
|
||||
return Arrays.stream(pathElements).reduce(HttpUtil::append).orElse("");
|
||||
}
|
||||
|
||||
@@ -54,6 +54,18 @@ import javax.servlet.http.HttpServletRequest;
|
||||
public class HttpUtilTest
|
||||
{
|
||||
|
||||
@Test
|
||||
public void concatenateTest() {
|
||||
assertEquals(
|
||||
"/scm/git/hitchhiker/tricia",
|
||||
HttpUtil.concatenate("/scm", "git", "hitchhiker", "tricia")
|
||||
);
|
||||
assertEquals(
|
||||
"scm/git/hitchhiker/tricia",
|
||||
HttpUtil.concatenate("scm", "git", "hitchhiker", "tricia")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user