Author: nbubna
Date: Mon Oct 20 15:44:54 2008
New Revision: 706439

URL: http://svn.apache.org/viewvc?rev=706439&view=rev
Log:
handle relative(null) better

Modified:
    
velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java

Modified: 
velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java
URL: 
http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java?rev=706439&r1=706438&r2=706439&view=diff
==============================================================================
--- 
velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java
 (original)
+++ 
velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java
 Mon Oct 20 15:44:54 2008
@@ -1234,7 +1234,8 @@
     /**
      * <p>Returns a copy of the link with the specified directory-relative
      * URI reference set as the end of the path and [EMAIL PROTECTED] 
#setForceRelative}
-     * set to true.</p>
+     * set to true. If the specified relative path is null, that is treated
+     * the same as an empty path.</p>
      *
      * Example:<br>
      * <code>&lt;a href='$link.relative("/login/index.vm")'&gt;Login 
Page&lt;/a&gt;</code><br>
@@ -1247,14 +1248,18 @@
      */
     public LinkTool relative(Object obj)
     {
+        LinkTool copy = relative();
+        // prepend relative paths with the current directory
+        String pth;
         if (obj == null)
         {
-            return path(getDirectory());
+            pth = getDirectory();
         }
-        String pth = String.valueOf(obj);
-        LinkTool copy = relative();
-        // prepend relative paths with the current directory
-        copy.setPath(combinePath(getDirectory(), pth));
+        else
+        {
+            pth = combinePath(getDirectory(), String.valueOf(obj));
+        }
+        copy.setPath(pth);
         return copy;
     }
 


Reply via email to