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();
		if (contextPath.startsWith("/")) {
			contextPath = contextPath.substring(1);
		}
		return join(contextPath, path);
	}
	
	public static String buildWebAppUrl(String path) {
		return buildWebAppUrl(WebHelper.getRequest(), path);
	}
}
@@ -574,24 +574,27 @@
 1);%0A%09%09%7D%0A
+%09%09%0A
 %09%09return
  join(co
@@ -585,16 +585,60 @@
 %09%09return
+ (StringUtils.isEmpty(contextPath)) ? path :
  join(co

Build URL with server context path.