Fix regex being too greedy
This commit is contained in:
parent
266b1a1fa8
commit
fe690fd13c
|
@ -97,7 +97,7 @@ namespace Ooui
|
||||||
public PublishedPath (string path, RequestHandler handler)
|
public PublishedPath (string path, RequestHandler handler)
|
||||||
{
|
{
|
||||||
Path = path;
|
Path = path;
|
||||||
RegexPath = new Regex (path);
|
RegexPath = new Regex ("^" + path + "$");
|
||||||
Handler = handler;
|
Handler = handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,26 @@ namespace Tests
|
||||||
Assert.AreEqual ("\"nvirueh4\"", r);
|
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/(?<id>[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]
|
[TestMethod]
|
||||||
public void PublishEmptyFile ()
|
public void PublishEmptyFile ()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue