+2007-04-16 Atsushi Enomoto <atsushi@ximian.com>
+
+ * Uri.cs : in Uri(baseUri,relativeUri,noEscape), relativeUri could
+ contain a URI scheme. In such cases the relativeUri could be still
+ relative (i.e. not always equivalent to absolute). Fixed bug #81382.
+
2007-03-05 Peter Dettman <peter.dettman@iinet.net.au>
* Uri.cs: This patch straightens out Equals/GetHashCode for the
// pos2 < 0 ... e.g. mailto
// pos2 > pos ... to block ':' in query part
if (pos2 > pos || pos2 < 0) {
- // equivalent to new Uri (relativeUri, dontEscape)
- source = relativeUri;
+ // in some cases, it is equivanent to new Uri (relativeUri, dontEscape):
+ // 1) when the URI scheme in the
+ // relative path is different from that
+ // of the baseUri, or
+ // 2) the URI scheme is non-standard
+ // ones (non-standard URIs are always
+ // treated as absolute here), or
+ // 3) the relative URI path is absolute.
+ if (String.CompareOrdinal (baseUri.Scheme, 0, relativeUri, 0, pos) != 0 ||
+ !IsPredefinedScheme (baseUri.Scheme) ||
+ relativeUri.Length > pos + 1 &&
+ relativeUri [pos + 1] == '/') {
+ source = relativeUri;
#if NET_2_0
- ParseUri ();
+ ParseUri ();
#else
- Parse ();
+ Parse ();
#endif
- return;
+ return;
+ }
+ else
+ relativeUri = relativeUri.Substring (pos + 1);
}
}
+2007-04-16 Atsushi Enomoto <atsushi@ximian.com>
+
+ * UriTest.cs : added relative .ctor() test where the relativeUris
+ contain URI schemes.
+
2007-01-25 Ilya Kharmatsky <ilyak -at- mainsoft.com>
* UriTypeConverterTest.cs: Added 'Ignore' attributes,
#endif
}
+ [Test]
+ public void RelativeUri2 ()
+ {
+ AssertEquals ("#1", "hoge:ext", new Uri (new Uri ("hoge:foo:bar:baz"), "hoge:ext").ToString ());
+ if (isWin32) {
+ AssertEquals ("#2-w", "file:///d:/myhost/ext", new Uri (new Uri ("file:///c:/localhost/bar"), "file:///d:/myhost/ext").ToString ());
+ AssertEquals ("#3-w", "file:///c:/localhost/myhost/ext", new Uri (new Uri ("file:///c:/localhost/bar"), "file:myhost/ext").ToString ());
+ AssertEquals ("#4-w", "uuid:ext", new Uri (new Uri ("file:///c:/localhost/bar"), "uuid:ext").ToString ());
+ AssertEquals ("#5-w", "file:///c:/localhost/ext", new Uri (new Uri ("file:///c:/localhost/bar"), "file:./ext").ToString ());
+ } else {
+ AssertEquals ("#2-u", "file:///d/myhost/ext", new Uri (new Uri ("file:///c/localhost/bar"), "file:///d/myhost/ext").ToString ());
+ AssertEquals ("#3-u", "file:///c/localhost/myhost/ext", new Uri (new Uri ("file:///c/localhost/bar"), "file:myhost/ext").ToString ());
+ AssertEquals ("#4-u", "uuid:ext", new Uri (new Uri ("file:///c/localhost/bar"), "uuid:ext").ToString ());
+ AssertEquals ("#5-u", "file:///c/localhost/ext", new Uri (new Uri ("file:///c/localhost/bar"), "file:./ext").ToString ());
+ }
+ AssertEquals ("#6", "http://localhost/ext", new Uri (new Uri ("http://localhost/bar"), "http:./ext").ToString ());
+ }
+
[Test]
public void ToStringTest()
{