I am writing my first Opa application. I am trying to set up a match for URL handling. The code is as follows:
function start(url)
{
match (url)
{
case {path:[] ...}: Resource.page("Home", home())
case {...}: Resource.page("nofindy", nofindy())
}
}
Server.start(Server.http, { dispatch: start })
It works like a charm, but now I want to be able to do synonymous comparisons. For example, I would like to be able to not only have / go to the home page, but also / home.
Is there a short way to do this, perhaps with the OR operator, or do I need to configure individual cases that run the same resource?
tl; dr: there is a better way to write the following snippet:
case {path:[] ...}: Resource.page("Home", home())
case {path:["home"] ...}: Resource.page("Home", home())
source
share