You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by je...@apache.org on 2002/09/29 11:02:36 UTC
cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/util URIUtil.java
jericho 2002/09/29 02:02:36
Modified: httpclient/src/java/org/apache/commons/httpclient/util
URIUtil.java
Log:
- Fix a bug to parse a string including 'virtual http url address'.
(URI class is ok. However URIUtil class was not ok. So now boths are ok.)
Revision Changes Path
1.2 +12 -9 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/util/URIUtil.java
Index: URIUtil.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/util/URIUtil.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- URIUtil.java 22 Sep 2002 05:19:50 -0000 1.1
+++ URIUtil.java 29 Sep 2002 09:02:36 -0000 1.2
@@ -92,8 +92,9 @@
public static String getPath(String uri) {
// consider of net_path
int at = uri.indexOf("//");
- int from = uri.indexOf("/", (at >= 0) ? at + 2 : 0);
- // Ignore the authority part of URI
+ int from = uri.indexOf("/", at >= 0 ?
+ (uri.lastIndexOf("/", at - 1) >= 0 ? 0 : at + 2) : 0);
+ // the authority part of URI ignored
int to = uri.length();
// check the query
if (uri.lastIndexOf("?") > from)
@@ -116,8 +117,9 @@
public static String getPathQuery(String uri) {
// consider of net_path
int at = uri.indexOf("//");
- int from = uri.indexOf("/", (at >= 0) ? at + 2 : 0);
- // Ignore the authority part of URI
+ int from = uri.indexOf("/", at >= 0 ?
+ (uri.lastIndexOf("/", at - 1) >= 0 ? 0 : at + 2) : 0);
+ // the authority part of URI ignored
int to = uri.length();
// Ignore the '?' mark so to ignore the query.
// check the fragment
@@ -137,7 +139,8 @@
public static String getFromPath(String uri) {
// consider of net_path
int at = uri.indexOf("//");
- int from = uri.indexOf("/", (at >= 0) ? at + 2 : 0);
+ int from = uri.indexOf("/", at >= 0 ?
+ (uri.lastIndexOf("/", at - 1) >= 0 ? 0 : at + 2) : 0);
// get the path and its rest.
return (from >= 0) ? uri.substring(from) : "/";
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>