You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2006/08/21 19:35:58 UTC

svn commit: r433299 - /incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/filters/InitFilter.java

Author: agilliland
Date: Mon Aug 21 10:35:58 2006
New Revision: 433299

URL: http://svn.apache.org/viewvc?rev=433299&view=rev
Log:
fixing calculation of absolute url path in init filter, which was broken in cases where app was deployed at root context and first request was to "/"


Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/filters/InitFilter.java

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/filters/InitFilter.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/filters/InitFilter.java?rev=433299&r1=433298&r2=433299&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/filters/InitFilter.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/filters/InitFilter.java Mon Aug 21 10:35:58 2006
@@ -78,8 +78,17 @@
         
         String fullUrl = request.getRequestURL().toString();
         
-        // first extract just the server portion of the url
-        url = fullUrl.substring(0, fullUrl.indexOf(request.getRequestURI()));
+        // if the uri is only "/" then we are basically done
+        if("/".equals(request.getRequestURI())) {
+            log.info(fullUrl.substring(0, fullUrl.length()-1));
+            return fullUrl.substring(0, fullUrl.length()-1);
+        }
+        
+        // find first "/" starting after hostname is specified
+        int index = fullUrl.indexOf("/", fullUrl.indexOf(request.getServerName()));
+        
+        // extract just the part leading up to uri
+        url = fullUrl.substring(0, index);
         
         // then just add on the context path
         url += request.getContextPath();