You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by nb...@apache.org on 2004/11/11 04:54:55 UTC
cvs commit: jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/tools LinkTool.java
nbubna 2004/11/10 19:54:55
Modified: src/java/org/apache/velocity/tools/view/tools LinkTool.java
Log:
fix bad URIs when webapp is installed as root (bug #32104)
Revision Changes Path
1.16 +11 -4 jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/tools/LinkTool.java
Index: LinkTool.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/tools/LinkTool.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- LinkTool.java 12 Mar 2004 20:30:32 -0000 1.15
+++ LinkTool.java 11 Nov 2004 03:54:55 -0000 1.16
@@ -311,14 +311,21 @@
*/
public LinkTool setRelative(String uri)
{
+ String ctxPath = request.getContextPath();
+ /* if the context path is the webapp root */
+ if (ctxPath.equals("/"))
+ {
+ /* then don't append anything for it */
+ ctxPath = "";
+ }
if (uri.startsWith("/"))
{
- return copyWith(request.getContextPath() + uri);
+ return copyWith(ctxPath + uri);
}
else
{
- return copyWith(request.getContextPath() + '/' + uri);
- }
+ return copyWith(ctxPath + '/' + uri);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org