Author: ivaynberg
Date: Thu Nov 16 10:53:29 2006
New Revision: 475862
URL: http://svn.apache.org/viewvc?view=rev&rev=475862
Log:
WICKET-82 Support case insensitive mount paths
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java?view=diff&rev=475862&r1=475861&r2=475862
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
Thu Nov 16 10:53:29 2006
@@ -94,11 +94,59 @@
/** cached url prefix. */
private CharSequence urlPrefix;
+ /** settings for the coding strategy */
+ private final Settings settings;
+
+ /**
+ * 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;
+
+ /**
+ * Sets mountsCaseSensitive.
+ *
+ * @param mountsCaseSensitive
+ * mountsCaseSensitive
+ */
+ public void setMountsCaseSensitive(boolean mountsCaseSensitive)
+ {
+ this.mountsCaseSensitive = mountsCaseSensitive;
+ }
+
+ /**
+ * Gets caseSensitive.
+ *
+ * @return caseSensitive
+ */
+ public boolean areMountsCaseSensitive()
+ {
+ return mountsCaseSensitive;
+ }
+ }
+
+
/**
* Construct.
*/
public WebRequestCodingStrategy()
{
+ this(new Settings());
+ }
+
+ /**
+ * Construct.
+ *
+ * @param settings
+ * settings to use for the coding strategy
+ */
+ public WebRequestCodingStrategy(Settings settings)
+ {
+ this.settings = settings;
}
/**
@@ -259,7 +307,27 @@
{
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();
}