Skip to content

Instantly share code, notes, and snippets.

@kohsuke
Created June 6, 2012 20:13
Show Gist options
  • Select an option

  • Save kohsuke/2884431 to your computer and use it in GitHub Desktop.

Select an option

Save kohsuke/2884431 to your computer and use it in GitHub Desktop.
public static String getActionUrl(String itUrl,Action action) {
String urlName = action.getUrlName();
if(urlName==null) return null; // to avoid NPE and fail to render the whole page
if(SCHEME.matcher(urlName).find())
return urlName; // absolute URL
if(urlName.startsWith("/"))
return joinPath(Stapler.getCurrentRequest().getContextPath(),urlName);
else
// relative URL name
return urlName;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment