state.elements.scheme = Uri.UriSchemeFile;
state.elements.delimiter = "://";
state.elements.isUnixFilePath = true;
- state.elements.isAbsoluteUri = (state.kind == UriKind.Relative)? false : true;
+ state.elements.isAbsoluteUri = state.kind == UriKind.Absolute;
if (part.Length >= 2 && part [0] == '/' && part [1] == '/') {
part = part.TrimStart (new char [] {'/'});
if (ch == '%'){
if (!Uri.IsHexEncoding (part, index))
return false;
+ var oldIndex = index;
ch = Uri.HexUnescape (part, ref index);
+ index--;
+ if (ch == '@') {
+ sb.Append (part.Substring (oldIndex, index - oldIndex + 1));
+ continue;
+ }
}
if (Char.IsLetterOrDigit (ch) || IsUnreserved (ch) || IsSubDelim (ch) || ch == ':'){
Assert.AreEqual ("id=1%262&sort=asc", escaped, "UriEscaped");
}
+ [Test]
+ public void RelativeOrAbsoluteUnixPath ()
+ {
+ var uri = new Uri ("/abc", UriKind.RelativeOrAbsolute);
+ Assert.IsFalse (uri.IsAbsoluteUri);
+ }
+
[Test]
// Bug #12631
public void LocalPathWithBaseUrl ()
var uri = new Uri ("/relative/path", UriKind.Relative);
uri.GetComponents (UriComponents.SerializationInfoString | UriComponents.Host, UriFormat.UriEscaped);
}
+
+ [Test]
+ public void UserInfo_EscapedLetter ()
+ {
+ var uri = new Uri ("https://first%61second@host");
+ Assert.AreEqual ("firstasecond", uri.UserInfo);
+ }
+
+ [Test]
+ public void UserInfo_EscapedAt ()
+ {
+ var userinfo = "first%40second";
+ var uri = new Uri ("https://" + userinfo + "@host");
+ Assert.AreEqual (userinfo, uri.UserInfo);
+ }
}
// Tests non default IriParsing