]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
[http uri] Trailing slashes in URIs were being discarded.
authorDaniel Ferstay <daniel.ferstay@citrix.com>
Tue, 28 Jul 2009 02:42:50 +0000 (19:42 -0700)
committerDaniel Ferstay <daniel.ferstay@citrix.com>
Tue, 28 Jul 2009 02:44:47 +0000 (19:44 -0700)
libs/http/uri.ml

index 7092899faeddbd9b925d1ff860f5e1d57af7532a..881acdb8619ef59d1f3f1a4621e939a61f47c07f 100644 (file)
@@ -112,8 +112,9 @@ let pct_decode s =
 *)
 let remove_dot_segments path =
        let slash = Str.regexp "/" in
-       let has_leading_slash p =
-               String.length p > 0 && p.[0] = '/' in
+       let path_len = String.length path in
+       let has_leading_slash = path_len > 0 && path.[0] = '/' in
+       let has_trailing_slash = path_len > 0 && path.[path_len - 1] = '/' in
        let rec remove in_segs out_segs =
                match in_segs, out_segs with
                | "." :: in_rest, _ ->
@@ -128,7 +129,8 @@ let remove_dot_segments path =
                        List.rev out_segs in
        let out_segs = remove (Str.split slash path) [] in
        let out = String.concat "/" out_segs in
-       if has_leading_slash path then "/" ^ out else out
+       let out = if has_leading_slash then "/" ^ out else out in
+       if has_trailing_slash then out ^ "/" else out
 
 (* Regular expression for authority = [userinfo "@"] host [":" port] *)
 let auth_re = "\\(\\([^@]*\\)@\\)?\\([^:]*\\)\\(:\\([0-9]*\\)\\)?"