diff --git a/Ooui/UI.cs b/Ooui/UI.cs index 8b35b96..eaac8d4 100644 --- a/Ooui/UI.cs +++ b/Ooui/UI.cs @@ -97,7 +97,7 @@ namespace Ooui public PublishedPath (string path, RequestHandler handler) { Path = path; - RegexPath = new Regex (path); + RegexPath = new Regex ("^" + path + "$"); Handler = handler; } } diff --git a/Tests/UITests.cs b/Tests/UITests.cs index de2425d..8639cdd 100644 --- a/Tests/UITests.cs +++ b/Tests/UITests.cs @@ -107,6 +107,26 @@ namespace Tests Assert.AreEqual ("\"nvirueh4\"", r); } + [TestMethod] + public void PatternUrlCompleteMatch () + { + bool gotRequest = false; + UI.PublishJson ("/", x => { + throw new Exception ("Pattern match failed to /"); + }); + UI.PublishJson ("/patter", x => { + throw new Exception ("Pattern match failed to /patter"); + }); + UI.PublishJson ("/pattern/(?[a-z0-9]+)", x => { + gotRequest = true; + Assert.AreEqual ("nvirueh4", x["id"]); + return x["id"]; + }); + var r = DownloadUI ("/pattern/nvirueh4"); + Assert.IsTrue (gotRequest); + Assert.AreEqual ("\"nvirueh4\"", r); + } + [TestMethod] public void PublishEmptyFile () {