RouterLink not encoding slashes correctly

Hi Vaadin team.

I recently noticed that the URLs in my application hadn’t encoded slashes correctly. I recreated the code in a sample project and hardcoded the parameters, and I had the same issue:

In the MainView:

        RouterLink link = new RouterLink("Open...", SecondView.class,
                new RouteParameters(new RouteParam("targetModel", "target/model") ,
                        new RouteParam("context", "context/name" ) ,
                        new RouteParam( "clientIdentifier", "client/identifier" )));

In the SecondView class:

@Route(value = "second-view/:clientIdentifier/:context/:targetModel")

the URL that was returned:

http://localhost:8080/second-view/client/identifier/context/name/target/model

I’d appreciate any assistance or suggested steps forward.

1 Like

I guess it just hasn’t been taken into account that / might be used in parameter values. To make this even more complicated, it might be fully valid to have a regular / in the value for a parameter that is at the end of the path but not for a parameter in the middle of a URL.

You can file a feature request in the Flow issue tracker.

The only workarounds that come to mind would be to use different separators in the values (e.g. client-identifier) or to build the URLs manually.

1 Like

Cross posting: Encoding slashes and other characters in RouterLink · Issue #19207 · vaadin/flow · GitHub