[Yanel-commits] rev 25139 -
public/yanel/trunk/src/contributions/resources/resource-creator/src/java/org/wyona/yanel/impl/resources
michi at wyona.com
michi at wyona.com
Thu Jun 14 14:35:25 CEST 2007
Author: michi
Date: 2007-06-14 14:35:25 +0200 (Thu, 14 Jun 2007)
New Revision: 25139
Modified:
public/yanel/trunk/src/contributions/resources/resource-creator/src/java/org/wyona/yanel/impl/resources/ResourceCreatorResource.java
Log:
remove too many slashes
Modified: public/yanel/trunk/src/contributions/resources/resource-creator/src/java/org/wyona/yanel/impl/resources/ResourceCreatorResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/resource-creator/src/java/org/wyona/yanel/impl/resources/ResourceCreatorResource.java 2007-06-14 12:03:40 UTC (rev 25138)
+++ public/yanel/trunk/src/contributions/resources/resource-creator/src/java/org/wyona/yanel/impl/resources/ResourceCreatorResource.java 2007-06-14 12:35:25 UTC (rev 25139)
@@ -395,6 +395,8 @@
}
log.error("DEBUG: Path of new resource: " + pathOfNewResource);
+ pathOfNewResource = new Path(removeTooManySlashes(pathOfNewResource.toString()));
+ log.error("DEBUG: Path of new resource without too many slashes: " + pathOfNewResource);
String rtps = getRequest().getParameter("resource-type");
String resNamespace = rtps.substring(0, rtps.indexOf("::"));
@@ -584,6 +586,28 @@
return sb;
}
+
+ /**
+ * Remove slashes if there are too many, e.g. /foo//bar.html is being transformed into /foo/bar.html
+ */
+ private String removeTooManySlashes(String path) {
+ StringBuffer sb = new StringBuffer();
+ boolean previousCharWasSlash = false;
+ for (int i = 0; i < path.length(); i++) {
+ char c = path.charAt(i);
+ if (c == '/' && previousCharWasSlash) {
+ log.error("DEBUG: Do not append this slash: " + i);
+ } else {
+ sb.append(c);
+ }
+ if (c == '/') {
+ previousCharWasSlash = true;
+ } else {
+ previousCharWasSlash = false;
+ }
+ }
+ return sb.toString();
+ }
}
/**
More information about the Yanel-commits
mailing list