Initializing an Uri previously throwed an exception when the URI scheme contained a digit (e.g. net.p2p).
The loop was missing a digit check, similar to https://github.com/mono/mono/blob/
1f1dc988ad7b165603a1175bf0a92156c4372c43/mcs/class/System/System/Uri.cs#L767
int index;
for (index = 1; index < part.Length; index++ ) {
char ch = part [index];
- if (ch != '.' && ch != '-' && ch != '+' && !IsAlpha (ch))
+ if (ch != '.' && ch != '-' && ch != '+' && !IsAlpha (ch) && !Char.IsDigit (ch))
break;
sb.Append (ch);
new Uri ("hey");
}
+ [Test]
+ public void SchemeWithDigits ()
+ {
+ Uri uri = new Uri ("net.p2p://foobar");
+ Assert.AreEqual ("net.p2p", uri.Scheme);
+ }
+
// on .NET 2.0 a port number is limited to UInt16.MaxValue
[ExpectedException (typeof (UriFormatException))]
[Test]