zillo32 / vosao

Automatically exported from code.google.com/p/vosao
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Work with slash ended URLs. #506

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
For example, if we access the two following URLs I would expect the
same result, but:
http://www.vosao.org/developer      -->  It works,
http://www.vosao.org/developer/     -->  Page not found.

Is that an accepted behaviour? or is that a bug? (I don't know) I've
been looking at the issues and I could not find a issue related with
that.

Original issue reported on code.google.com by kinyelo@gmail.com on 6 Aug 2011 at 4:52

GoogleCodeExporter commented 8 years ago
What about adding this in SiteFilter?

if (url.endsWith("/")) {
   httpResponse.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
   httpResponse.setHeader("Location", url.substring(0, url.length() -1 ));
   httpResponse.setHeader("Connection", "close");
   return;
}

Theorically there should be no URLs stored at Vosao with a trailing slash, it 
is not allowed to use a slash when defining a URL. However, one can use the 
slash when defining SEO Urls, so at least the code should be inserted after the 
conditional checking for SEO Urls at line 115.

In my opinion, line 135 after url.equals("/") conditional would be a good 
place. This way we don't need to check if the url is equals to "/", and more 
important, we should see this case unusual and not likely to happen. So instead 
of unnecessarily checking every correct URL without and slash at the end, we 
will handled it at the end.

Original comment by raimon.r...@rarejava.com on 16 Aug 2011 at 12:22

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r1088.

Original comment by kinyelo@gmail.com on 16 Aug 2011 at 5:58