Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2012-02-19 21:08:57 +0400
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2012-02-19 21:08:57 +0400
commitbd0c4311b36d169b1179ac928ebf20fd944d9565 (patch)
treef83dcc530406fc2a5abad5cd052acb209fb72bd1 /mcs/class/System.ServiceModel.Web
parentfcb00cefa9b7575ce694af2fa39e178e07666162 (diff)
parentbb8d09d41d5032c18a5a28779a19591601b67d82 (diff)
Merge pull request #226 from petejohanson/uri-templates-unprefixed-wildcard
Fix Bug #658, allowing uri templates with no text preceding a wildcard.
Diffstat (limited to 'mcs/class/System.ServiceModel.Web')
-rw-r--r--mcs/class/System.ServiceModel.Web/System/UriTemplate.cs2
-rw-r--r--mcs/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs26
2 files changed, 27 insertions, 1 deletions
diff --git a/mcs/class/System.ServiceModel.Web/System/UriTemplate.cs b/mcs/class/System.ServiceModel.Web/System/UriTemplate.cs
index 177e860c073..c1c0018ceae 100644
--- a/mcs/class/System.ServiceModel.Web/System/UriTemplate.cs
+++ b/mcs/class/System.ServiceModel.Web/System/UriTemplate.cs
@@ -303,7 +303,7 @@ namespace System
if (tEnd < 0)
tEnd = template.Length;
if (wild)
- tEnd = wildIdx - 1;
+ tEnd = Math.Max (wildIdx - 1, 0);
if (!wild && (cp.Length - c) != (tEnd - i) ||
String.CompareOrdinal (cp, c, template, i, tEnd - i) != 0)
return null; // suffix doesn't match
diff --git a/mcs/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs b/mcs/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs
index b72f2ff04af..8455ce59340 100644
--- a/mcs/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs
+++ b/mcs/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs
@@ -426,6 +426,32 @@ namespace MonoTests.System
}
[Test]
+ public void MatchWildcard2 ()
+ {
+ var t = new UriTemplate ("*");
+ var m = t.Match (new Uri ("http://localhost"), new Uri ("http://localhost/hoge/ppp"));
+ Assert.IsNotNull (m, "#0");
+ Assert.IsEmpty (m.QueryParameters, "#1.0");
+ Assert.AreEqual ("hoge", m.WildcardPathSegments [0], "#2");
+ Assert.AreEqual ("ppp", m.WildcardPathSegments [1], "#3");
+ }
+
+ [Test]
+ public void MatchWildcard3 ()
+ {
+ var t = new UriTemplate ("*?p1={foo}");
+ var m = t.Match (new Uri ("http://localhost"), new Uri ("http://localhost/hoge/ppp/qqq?p1=v1"));
+ Assert.IsNotNull (m, "#0");
+ Assert.IsNotNull (m.QueryParameters, "#1.0");
+ Assert.AreEqual ("v1", m.QueryParameters ["p1"], "#1");
+ Assert.IsNotNull (m.WildcardPathSegments, "#2.0");
+ Assert.AreEqual (3, m.WildcardPathSegments.Count, "#2");
+ Assert.AreEqual ("hoge", m.WildcardPathSegments [0], "#3");
+ Assert.AreEqual ("ppp", m.WildcardPathSegments [1], "#4");
+ Assert.AreEqual ("qqq", m.WildcardPathSegments [2], "#5");
+ }
+
+ [Test]
public void IgnoreTrailingSlash ()
{
var t = new UriTemplate ("/{foo}/{bar}", true);