Closed hernangm closed 8 years ago
Thanks for reporting this! Sorry for the delay in replying. I'll look into this in the new year. In the meantime, feel free to send a pull request if you resolve the issue :)
Just getting back into things now. Is an empty string really a valid URL? Wouldn't it be /
for the root?
Hi Daniel,
I have the following controller
public class HomeController : Controller
{
[HttpGet, Route("")]
public virtual ActionResult Index()
{
return View();
}
}
but when I call
Router.action("Home", "Index") in my js files I get some exception, although the route does exist in the list of registered routes as
"{"route":{"url":"","defaults":{"controller":"Home","action":"Index"},"constraints":{},"optional":[]},"_params":[],"_parsedConstraints":{}}"
I did some debugging and the problem seems to be here:
// Try to merge all URL parameters
// If null, this means a required parameters was not specified.
finalUrl = this._merge(finalValues, processedParams);
if (!finalUrl) {
return null;
}
When finalUrl is "", that is evaluated by !finalUrl as a truish value, returning null. I think it could be fixed if finalUrl is checked against null directly.
Good catch, thanks! I'll try to take a look soon.
An empty string is a valid url resolvable from a route. However when finalUrl is an empty string, it returns null and it should return the empty string.