2008-10-17 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 17 Oct 2008 14:59:28 +0000 (14:59 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 17 Oct 2008 14:59:28 +0000 (14:59 -0000)
* UrlPattern.cs : fixed pattern match for such string that has
  suffix. (DynamicData uses it.)

* RouteTest.cs : added test for DynamicData default pattern.

svn path=/trunk/mcs/; revision=116234

mcs/class/System.Web.Routing/System.Web.Routing/ChangeLog
mcs/class/System.Web.Routing/System.Web.Routing/UrlPattern.cs
mcs/class/System.Web.Routing/Test/System.Web.Routing/ChangeLog
mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs

index 4cda19e903b2ee6c1e429f6bca0d5cf1b5a1899e..8e8cc1a47ec8dfdb3570ba4d96d57eaf283a0d91 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UrlPattern.cs : fixed pattern match for such string that has
+         suffix. (DynamicData uses it.)
+
 2008-10-16  Atsushi Enomoto  <atsushi@ximian.com>
 
        * RouteValueDictionary.cs : object argument is actually for
index dc2402997cea16b38c5502256b3a4fa0d4e9b816..f7ab679842d39b80ec5831baa56fbcf59c1266c7 100644 (file)
@@ -136,12 +136,14 @@ namespace System.Web.Routing
                                                int end = t.IndexOf ('}', start + 1);
                                                int next = t.IndexOf ('{', end + 1);
                                                string key = t.Substring (start + 1, end - start - 1);
+                                               string nextToken = next < 0 ? t.Substring (end + 1) : t.Substring (end + 1, next - end - 1);
+                                               int vnext = nextToken.Length > 0 ? v.IndexOf (nextToken, vfrom + 1, StringComparison.Ordinal) : -1;
+
                                                if (next < 0) {
-                                                       tmp.Add (key, vfrom == 0 ? v : v.Substring (vfrom));
-                                                       vfrom = v.Length;
+                                                       var vs = vnext < 0 ? v.Substring (vfrom) : v.Substring (vfrom, vnext - vfrom);
+                                                       tmp.Add (key, vs);
+                                                       vfrom = vs.Length;
                                                } else {
-                                                       string nextToken = t.Substring (end + 1, next - end - 1);
-                                                       int vnext = v.IndexOf (nextToken, vfrom + 1, StringComparison.Ordinal);
                                                        if (vnext < 0)
                                                                return null; // mismatch
                                                        tmp.Add (key, v.Substring (vfrom, vnext - vfrom));
index a0ca7e993f60a94916c9387d2bad5a3bed8d8de3..0cebbaa11dc944d00f2e8aab0c95808e01ece023 100644 (file)
@@ -1,3 +1,7 @@
+2008-10-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * RouteTest.cs : added test for DynamicData default pattern.
+
 2008-10-16  Atsushi Enomoto  <atsushi@ximian.com>
 
        * RouteValueDictionaryTest.cs : new test.
index 7e5f749b97e83bc02edbc0de88fe7c1f88bc7a2f..b309f97e9ba125797be6d6c78760e08a622a0888 100644 (file)
@@ -247,6 +247,16 @@ namespace MonoTests.System.Web.Routing
                        Assert.AreEqual (2, rd.Values.Count, "#7-3");
                }
 
+               [Test]
+               public void GetRouteData6 ()
+               {
+                       var r = new Route ("{table}/{action}.aspx", null);
+                       var rd = r.GetRouteData (new HttpContextStub ("~/FooTable/List.aspx", String.Empty));
+                       Assert.IsNotNull (rd, "#1");
+                       Assert.AreEqual ("FooTable", rd.Values ["table"], "#2");
+                       Assert.AreEqual ("List", rd.Values ["action"], "#3");
+               }
+
                [Test]
                [ExpectedException (typeof (ArgumentNullException))]
                public void GetVirtualPathNullContext ()