mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 11:21:08 -10:00
[wcf] UriTemplate must trim the first leading slash in the rendered template.
When using BindBy{Name,Position} UriTemplate must remove the the first slash from
the rendered URI. This fixes the 4 failing tests.
This commit is contained in:
1 parent
950369e856
commit
6005f0a7df
2 files changed
+35
-2
No files matched your search
@@ -128,6 +128,17 @@ namespace System
|
||||
return BindByNameCommon (baseAddress, null, parameters, omitDefaults);
|
||||
}
|
||||
|
||||
string TrimRenderedUri (StringBuilder sb)
|
||||
{
|
||||
if (sb.Length == 0)
|
||||
return String.Empty;
|
||||
|
||||
if (sb [0] == '/')
|
||||
sb.Remove (0, 1);
|
||||
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
Uri BindByNameCommon (Uri baseAddress, NameValueCollection nvc, IDictionary<string,string> dic, bool omitDefaults)
|
||||
{
|
||||
CheckBaseAddress (baseAddress);
|
||||
@@ -141,7 +152,7 @@ namespace System
|
||||
BindByName (ref src, sb, path, nvc, dic, omitDefaults, false);
|
||||
BindByName (ref src, sb, query, nvc, dic, omitDefaults, true);
|
||||
sb.Append (template.Substring (src));
|
||||
return new Uri (baseAddress.ToString () + sb.ToString ());
|
||||
return new Uri (baseAddress.ToString () + TrimRenderedUri (sb));
|
||||
}
|
||||
|
||||
void BindByName (ref int src, StringBuilder sb, ReadOnlyCollection<string> names, NameValueCollection nvc, IDictionary<string,string> dic, bool omitDefaults, bool query)
|
||||
@@ -184,7 +195,7 @@ namespace System
|
||||
BindByPosition (ref src, sb, path, values, ref index);
|
||||
BindByPosition (ref src, sb, query, values, ref index);
|
||||
sb.Append (template.Substring (src));
|
||||
return new Uri (baseAddress.ToString () + sb.ToString ());
|
||||
return new Uri (baseAddress.ToString () + TrimRenderedUri (sb));
|
||||
}
|
||||
|
||||
void BindByPosition (ref int src, StringBuilder sb, ReadOnlyCollection<string> names, string [] values, ref int index)
|
||||
|
||||
@@ -217,6 +217,28 @@ namespace MonoTests.System
|
||||
Assert.AreEqual ("http://localhost/value2/value1/", u.ToString ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindByNameManySlashes ()
|
||||
{
|
||||
var t = new UriTemplate ("////{foo}/{bar}/");
|
||||
var n = new NameValueCollection ();
|
||||
n.Add ("Bar", "value1"); // case insensitive
|
||||
n.Add ("FOO", "value2"); // case insensitive
|
||||
var u = t.BindByName (new Uri ("http://localhost/"), n);
|
||||
Assert.AreEqual ("http://localhost////value2/value1/", u.ToString ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindByNameManySlashes2 ()
|
||||
{
|
||||
var t = new UriTemplate ("////{foo}/{bar}/");
|
||||
var n = new NameValueCollection ();
|
||||
n.Add ("Bar", "value1"); // case insensitive
|
||||
n.Add ("FOO", "value2"); // case insensitive
|
||||
var u = t.BindByName (new Uri ("http://localhost//"), n);
|
||||
Assert.AreEqual ("http://localhost/////value2/value1/", u.ToString ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindByNameWithDefaults ()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user