DotVVM route parameters break when optional segments contain dashes

Hi everyone!

I am using DotVVM’s routing system with optional parameters like /products/{category?} and noticed strange behavior when the parameter value includes a dash (e.g., “home-appliances”). :innocent: The route either doesn’t match / falls back to the default page; even though manually navigating to the URL should work.

I have confirmed that the parameter gets passed correctly when the value is a single word (like “electronics”); but using slugs with hyphens which are common in SEO-friendly URLs seems to break parameter binding. :upside_down_face:I suspect it has to do with how DotVVM parses & binds the optional segments. Checked Overview | DotVVM Documentation Selenium Course Online guide related to this and found it quite informative.

Is there a way to configure DotVVM’s routing system to safely accept hyphenated strings in optional parameters without breaking route resolution? :thinking: Or do I need to encode these manually and decode them in the viewmodel?

Thank you !! :slightly_smiling_face:

Hi! This looks like a bug on our side, dashes should be normally allowed in the parameters (only slashes / should be restricted). However, I’m unable to replicate the problem in my setup. Could you please share more details on the exact setup? (i.e. an example code which reproduces the problem.). Is this the only route with the problem, or do other routes have the same behavior of not accepting dashes in path?

Can you reproduce it with this minimal setup?

var route = new DotvvmRoute("products/{category?}", null, "testpage", null, null, configuration);
IDictionary<string, object> parameters;
Assert.IsTrue(route.IsMatch("products/home-appliances", out parameters));

In any case, you can probably workaround it before we can figure what is going on: If the parameter works fine when not optional, you can register two routes for one page: one with the parameter and one without, emulating the maybe-broken DotVVM optional parameter handling.