package com.github.aureliano.verbum_domini.helper;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;

public final class UrlHelper {

	private UrlHelper() {
		super();
	}
	
	public static String join(Object...tokens) {
		return "/" + StringUtils.join(tokens, '/');
	}
	
	public static String buildWebAppUrl(ServletRequest request, String path) {
		String contextPath = ((HttpServletRequest) request).getContextPath();
		return join(contextPath.substring(1), path);
	}
	
	public static String buildWebAppUrl(String path) {
		return buildWebAppUrl(WebHelper.getRequest(), path);
	}
}
@@ -492,16 +492,100 @@
 th();%0A%09%09
+if (contextPath.startsWith(%22/%22)) %7B%0A%09%09%09contextPath = contextPath.substring(1);%0A%09%09%7D%0A%09%09
 return j
@@ -599,29 +599,16 @@
 textPath
-.substring(1)
 , path);

Build URL with server context path.