Route param encoding

It seems like aurelia is not correctly encoding url params containing a ‘/’:

<a route-href="route: test; params.bind: { param: 'document/1' }">Test</a>

This route-href leads to the url “/test/document/1”, but it should be “/test/document%2F1”. Is it possible to change this behaviour globally?

We are moving a big AngularJs business application to aurelia, there we have a lot of ids containing a ‘/’, this leads to lots of routing problems.

1 Like

you could copy the route-href attribute and create your own in which the params values are url encoded

1 Like

Maybe it’s difficult for router to know whether it needs to be encoded.
For example the same binding can work against two different router configs

route: 'test/:param', // ideally param should be encoded automatically


route: 'test/*param', // here param is a sub path, slash is preserved

The second form can fix your bug and the url is very readable because of no encoding at all.

1 Like

OK, thanks for your help guys! I managed it by overwriting router.generate…

As this is kind of a hack, do you already know if this will this be solved in aurelia 2?

Just tried it out:

It’s fixed in Aurelia 2! :heart_eyes: