Author: ivaynberg
Date: Thu Nov 16 10:47:12 2006
New Revision: 475859
URL: http://svn.apache.org/viewvc?view=rev&rev=475859
Log:
WICKET-82 Support case insensitive mount paths
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
Modified:
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java?view=diff&rev=475859&r1=475858&r2=475859
==============================================================================
---
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
(original)
+++
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
Thu Nov 16 10:47:12 2006
@@ -88,6 +88,50 @@
public static final String IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME =
NAME_SPACE
+ "ignoreIfNotActive";
+ /**
+ * Various settings used to configure this strategy
+ *
+ * @author ivaynberg
+ */
+ public static class Settings
+ {
+ /** whether or not mount paths are case sensitive */
+ private boolean mountsCaseSensitive = true;
+
+ /**
+ * Construct.
+ */
+ public Settings()
+ {
+ }
+
+ /**
+ * Sets mountsCaseSensitive.
+ *
+ * @param mountsCaseSensitive
+ * mountsCaseSensitive
+ */
+ public void setMountsCaseSensitive(boolean mountsCaseSensitive)
+ {
+ this.mountsCaseSensitive = mountsCaseSensitive;
+ }
+
+ /**
+ * Gets caseSensitive.
+ *
+ * @return caseSensitive
+ */
+ public boolean areMountsCaseSensitive()
+ {
+ return mountsCaseSensitive;
+ }
+ }
+
+
+ /** settings for the coding strategy */
+ private final Settings settings;
+
+
/** Comparator implementation that sorts longest strings first */
private static final Comparator lengthComparator = new Comparator()
{
@@ -145,9 +189,25 @@
*/
public WebRequestCodingStrategy()
{
+ this(new Settings());
}
/**
+ * Construct.
+ *
+ * @param settings
+ */
+ public WebRequestCodingStrategy(Settings settings)
+ {
+ if (settings == null)
+ {
+ throw new IllegalArgumentException("Argument
[[settings]] cannot be null");
+ }
+ this.settings = settings;
+ }
+
+
+ /**
* @see wicket.request.IRequestCodingStrategy#decode(wicket.Request)
*/
public final RequestParameters decode(final Request request)
@@ -265,7 +325,26 @@
{
final Map.Entry entry = (Entry)it.next();
final String key = (String)entry.getKey();
- if (path.startsWith(key))
+ boolean match = false;
+ if (!settings.areMountsCaseSensitive())
+ {
+ if (path.length() >= key.length())
+ {
+ String mount =
path.substring(0, key.length());
+ if (mount.equalsIgnoreCase(key))
+ {
+ match = true;
+ }
+ }
+ }
+ else
+ {
+ if (path.startsWith(key))
+ {
+ match = true;
+ }
+ }
+ if (match)
{
return
(IRequestTargetUrlCodingStrategy)entry.getValue();
}
@@ -614,7 +693,7 @@
if (parameters != null)
{
Iterator it = parameters.keySet().iterator();
- while(it.hasNext())
+ while (it.hasNext())
{
final String key = (String)it.next();
final String value = parameters.getString(key);