Fix building relative URIs

Examples:

testURI --relative --base file:///a file:///b
New correct result: b
Old incorrect result: ../b

testURI --relative --base file:///a file:///
New correct result: ./
Old incorrect result: ../

testURI --relative --base file:///a/b file:///a/
New correct result: ./
Old incorrect result: ../../a/
diff --git a/uri.c b/uri.c
index 84e420a..4901a11 100644
--- a/uri.c
+++ b/uri.c
@@ -2280,20 +2280,11 @@
 	 * beginning of the "unique" suffix of URI
 	 */
 	ix = pos;
-	if ((rptr[ix] == '/') && (ix > 0))
-	    ix--;
-	else if ((rptr[ix] == 0) && (ix > 1) && (rptr[ix - 1] == '/'))
-	    ix -= 2;
 	for (; ix > 0; ix--) {
-	    if (rptr[ix] == '/')
+	    if (rptr[ix - 1] == '/')
 		break;
 	}
-	if (ix == 0) {
-	    uptr = (xmlChar *)rptr;
-	} else {
-	    ix++;
-	    uptr = (xmlChar *)&rptr[ix];
-	}
+	uptr = (xmlChar *)&rptr[ix];
 
 	/*
 	 * In base, count the number of '/' from the differing point
@@ -2304,6 +2295,15 @@
 		    nbslash++;
 	    }
 	}
+
+	/*
+	 * e.g: URI="foo/" base="foo/bar" -> "./"
+	 */
+	if (nbslash == 0 && !uptr[0]) {
+	    val = xmlStrdup(BAD_CAST "./");
+	    goto done;
+	}
+
 	len = xmlStrlen (uptr) + 1;
     }