# Route param encoding

**URL:** <https://discourse.aurelia.io/t/route-param-encoding/3795>\
**Category:** Uncategorized\
**Created:** [September 24, 2020, 12:55pm UTC](https://discourse.aurelia.io/t/route-param-encoding/3795 "2020-09-24T12:55:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elitastic](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elitastic/32/1787_2.png) [@elitastic](https://discourse.aurelia.io/u/elitastic)\
**Post date:** [September 24, 2020, 12:55pm UTC](https://discourse.aurelia.io/t/route-param-encoding/3795/1 "2020-09-24T12:55:57Z")

</div>

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

> **[Dumber Gist](https://gist.dumber.app/?gist=5c180b42d73da0367a65c7b0a1477163)**

```
<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.

---

<div class="post-metadata">

**Author:** ![jbockle](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/jbockle/32/607_2.png) [@jbockle](https://discourse.aurelia.io/u/jbockle)\
**Post date:** [September 24, 2020, 9:10pm UTC](https://discourse.aurelia.io/t/route-param-encoding/3795/2 "2020-09-24T21:10:03Z")

</div>

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

> **[Dumber Gist](https://gist.dumber.app/?gist=cc7b8eea64b6c5bf9965ca3ff95909b6)**

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [September 24, 2020, 10:59pm UTC](https://discourse.aurelia.io/t/route-param-encoding/3795/3 "2020-09-24T22:59:35Z")

</div>

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

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

```

and

```auto
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.

---

<div class="post-metadata">

**Author:** ![elitastic](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elitastic/32/1787_2.png) [@elitastic](https://discourse.aurelia.io/u/elitastic)\
**Post date:** [September 25, 2020, 9:21am UTC](https://discourse.aurelia.io/t/route-param-encoding/3795/4 "2020-09-25T09:21:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![elitastic](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elitastic/32/1787_2.png) [@elitastic](https://discourse.aurelia.io/u/elitastic)\
**Post date:** [September 25, 2020, 9:36am UTC](https://discourse.aurelia.io/t/route-param-encoding/3795/5 "2020-09-25T09:36:35Z")

</div>

Just tried it out: [https://gist.dumber.app/?gist=b3a21372f4ebb0751fe94d8866aa3dc0](https://gist.dumber.app/?gist=b3a21372f4ebb0751fe94d8866aa3dc0)

It’s fixed in Aurelia 2! 😍
