velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r740383 - in /velocity/tools/trunk/src: main/java/org/apache/velocity/tools/generic/LinkTool.java test/java/org/apache/velocity/tools/LinkToolTests.java
Date Tue, 03 Feb 2009 19:26:19 GMT
Author: nbubna
Date: Tue Feb  3 19:26:19 2009
New Revision: 740383

URL: http://svn.apache.org/viewvc?rev=740383&view=rev
Log:
leave fragment encoding to URL class so it doesn't happen twice

Modified:
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/LinkToolTests.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=740383&r1=740382&r2=740383&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 Tue
Feb  3 19:26:19 2009
@@ -912,15 +912,10 @@
             // fail if there was an error in setting the port
             if (port > -2)
             {
-                String anchor = this.fragment;
-                if (anchor != null)
-                {
-                    anchor = encode(anchor);
-                }
                 if (opaque)
                 {
                     // path is used as scheme-specific part
-                    return new URI(scheme, path, anchor);
+                    return new URI(scheme, path, fragment);
                 }
                 else if (forceRelative)
                 {
@@ -928,7 +923,7 @@
                     {
                         return null;
                     }
-                    return new URI(null, null, null, -1, path, toQuery(query), anchor);
+                    return new URI(null, null, null, -1, path, toQuery(query), fragment);
                 }
                 else
                 {
@@ -938,7 +933,7 @@
                     {
                         return null;
                     }
-                    return new URI(scheme, user, host, port, path, toQuery(query), anchor);
+                    return new URI(scheme, user, host, port, path, toQuery(query), fragment);
                 }
             }
         }

Modified: velocity/tools/trunk/src/test/java/org/apache/velocity/tools/LinkToolTests.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/test/java/org/apache/velocity/tools/LinkToolTests.java?rev=740383&r1=740382&r2=740383&view=diff
==============================================================================
--- velocity/tools/trunk/src/test/java/org/apache/velocity/tools/LinkToolTests.java (original)
+++ velocity/tools/trunk/src/test/java/org/apache/velocity/tools/LinkToolTests.java Tue Feb
 3 19:26:19 2009
@@ -778,7 +778,7 @@
         assertEquals(null, link.toString());
         link = newInstance("/foo#bar");
         link.setFragment("woo gie");
-        assertEquals("/foo#woo+gie", link.toString());
+        assertEquals("/foo#woo%20gie", link.toString());
     }
 
     public @Test void methodGetAnchor() throws Exception
@@ -807,7 +807,7 @@
         assertEquals("a b", link.anchor(space).getAnchor());
         link = newInstance("http://go.com#foo");
         assertEquals("http://go.com#true", link.anchor(true).toString());
-        assertEquals("http://go.com#a+b", link.anchor(space).toString());
+        assertEquals("http://go.com#a%20b", link.anchor(space).toString());
     }
 
     public @Test void methodGetSelf() throws Exception



Mime
View raw message