httplite: fix resource path creation. Remove redundant path separator char.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1228772 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/httplite/minimum/src/main/java/org/apache/felix/httplite/server/ResourceHandler.java b/httplite/minimum/src/main/java/org/apache/felix/httplite/server/ResourceHandler.java
index ae0be7c..926e1de 100644
--- a/httplite/minimum/src/main/java/org/apache/felix/httplite/server/ResourceHandler.java
+++ b/httplite/minimum/src/main/java/org/apache/felix/httplite/server/ResourceHandler.java
@@ -49,6 +49,7 @@
private final String m_name;
private final String m_alias;
private final Logger m_logger;
+ private final int m_aliasIndex;
/**
* @param req HttpRequest
@@ -69,6 +70,7 @@
this.m_httpContext = resource.getContext();
this.m_name = resource.getName();
this.m_alias = resource.getAlias();
+ this.m_aliasIndex = m_alias.length() + 1;
this.m_logger = logger;
}
@@ -122,6 +124,13 @@
*/
private String getResourceName(final String path)
{
- return m_name + "/" + path.substring(m_alias.length());
+ //Ensure that the path begins at root.
+ String rpath = path;
+ if (!path.startsWith( "/" ))
+ {
+ rpath = "/" + path;
+ }
+
+ return m_name + "/" + rpath.substring(m_aliasIndex);
}
}