Skip to content

Commit

Permalink
Fix routing of CatchAll tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel15 committed Feb 24, 2014
1 parent b1e8599 commit cf123b1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Expand Up @@ -606,7 +606,7 @@ public string BuildUrl (Route route, RequestContext requestContext, RouteValueDi
pendingPartsAreAllSafe = true;
pendingParts.Append (token.Name);
} else {
if (token.Type == PatternTokenType.Standard) {
if (token.Type == PatternTokenType.Standard || token.Type == PatternTokenType.CatchAll) {
if (pendingPartsAreAllSafe) {
// Accept
if (pendingParts.Length > 0) {
Expand Down
30 changes: 30 additions & 0 deletions mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs
Expand Up @@ -1723,6 +1723,36 @@ public void GetVirtualPath25()
Assert.AreEqual("2013/08/hello-world", vp.VirtualPath, "#2");
}

[Test (Description = "Xamarin Bug #17960")]
public void GetVirtualPathWithCatchall1()
{
var r = new MyRoute("HelloWorld/{*path}", new MyRouteHandler());
var hc = new HttpContextStub2("~/", String.Empty);
var values = new RouteValueDictionary()
{
{ "path", "foobar" },
};
var vp = r.GetVirtualPath(new RequestContext(hc, new RouteData()), values);

Assert.IsNotNull(vp, "#1");
Assert.AreEqual("HelloWorld/foobar", vp.VirtualPath, "#2");
}

[Test (Description = "Xamarin Bug #17960")]
public void GetVirtualPathWithCatchall2()
{
var r = new MyRoute("HelloWorld/{*path}", new MyRouteHandler());
var hc = new HttpContextStub2("~/", String.Empty);
var values = new RouteValueDictionary()
{
{ "path", "foo/bar/baz" },
};
var vp = r.GetVirtualPath(new RequestContext(hc, new RouteData()), values);

Assert.IsNotNull(vp, "#1");
Assert.AreEqual("HelloWorld/foo/bar/baz", vp.VirtualPath, "#2");
}

// Bug #500739
[Test]
public void RouteGetRequiredStringWithDefaults ()
Expand Down

0 comments on commit cf123b1

Please sign in to comment.