sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r632389 - /incubator/sling/trunk/sling/servlets-default/src/main/java/org/apache/sling/servlets/RedirectServlet.java
Date Fri, 29 Feb 2008 16:58:45 GMT
Author: fmeschbe
Date: Fri Feb 29 08:58:34 2008
New Revision: 632389

URL: http://svn.apache.org/viewvc?rev=632389&view=rev
Log:
SLING-296 Add support for realtive target paths

Modified:
    incubator/sling/trunk/sling/servlets-default/src/main/java/org/apache/sling/servlets/RedirectServlet.java

Modified: incubator/sling/trunk/sling/servlets-default/src/main/java/org/apache/sling/servlets/RedirectServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-default/src/main/java/org/apache/sling/servlets/RedirectServlet.java?rev=632389&r1=632388&r2=632389&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlets-default/src/main/java/org/apache/sling/servlets/RedirectServlet.java
(original)
+++ incubator/sling/trunk/sling/servlets-default/src/main/java/org/apache/sling/servlets/RedirectServlet.java
Fri Feb 29 08:58:34 2008
@@ -140,12 +140,23 @@
         }
 
 
-        StringBuffer pathBuf = new StringBuffer();
-
         String basePath = request.getResource().getPath();
+        
+        // make sure the target path is absolute
+        if (!targetPath.startsWith("/")) {
+            if (!basePath.endsWith("/")) {
+                targetPath = "/".concat(targetPath);
+            }
+            targetPath = basePath.concat(targetPath);
+        }
+        
+        // append optional selectors etc.to the base path
         if (postFix != null) {
-            basePath += postFix;
+            basePath = basePath.concat(postFix);
         }
+
+        StringBuffer pathBuf = new StringBuffer();
+
 
         makeRelative(pathBuf, basePath, targetPath);
 



Mime
View raw message