Revision: 621
http://stripes.svn.sourceforge.net/stripes/?rev=621&view=rev
Author: bengunter
Date: 2007-11-15 19:54:40 -0800 (Thu, 15 Nov 2007)
Log Message:
-----------
Fixed STS-399: @UrlBinding should ignore trailing slash. Any trailing slashes
in the URI are now ignored.
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
Modified:
trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
2007-11-12 12:27:50 UTC (rev 620)
+++ trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
2007-11-16 03:54:40 UTC (rev 621)
@@ -147,13 +147,18 @@
if (prototype == null)
return null;
+ // ignore trailing slashes in the URI
+ int length = uri.length();
+ while (uri.charAt(length - 1) == '/')
+ --length;
+
// extract the request parameters and add to new binding object
ArrayList<Object> components = new
ArrayList<Object>(prototype.getComponents().size());
int index = prototype.getPath().length();
UrlBindingParameter current = null;
String value = null;
Iterator<Object> iter = prototype.getComponents().iterator();
- while (index < uri.length() && iter.hasNext()) {
+ while (index < length && iter.hasNext()) {
Object component = iter.next();
if (component instanceof String) {
// extract the parameter value from the URI
@@ -164,8 +169,8 @@
index = end + literal.length();
}
else {
- value = uri.substring(index);
- index = uri.length();
+ value = uri.substring(index, length);
+ index = length;
}
// add to the binding
@@ -182,8 +187,8 @@
}
// if component iterator ended before end of string, then grab
remainder of string
- if (index < uri.length()) {
- value = uri.substring(index);
+ if (index < length) {
+ value = uri.substring(index, length);
}
// parameter was last component in list
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development