# URL encoding and back-button issue in CanJS

**URL:** <https://forums.bitovi.com/t/url-encoding-and-back-button-issue-in-canjs/826>\
**Category:** CanJS\
**Created:** [March 20, 2018, 6:26pm UTC](https://forums.bitovi.com/t/url-encoding-and-back-button-issue-in-canjs/826 "2018-03-20T18:26:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prafull\_Dhadkar](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@Prafull\_Dhadkar](https://forums.bitovi.com/u/Prafull_Dhadkar)\
**Post date:** [March 20, 2018, 6:26pm UTC](https://forums.bitovi.com/t/url-encoding-and-back-button-issue-in-canjs/826/1 "2018-03-20T18:26:04Z")

</div>

Hi Team  
I am working on an application in which we are using CanJS 1.1. Because of some restrictions, we cannot upgrade our CanJS version.

we have set our URL format like “www.example.abc#!load/view/pid=123/false” and below is the routing function for this URL

“load/:type/:data/:isConfig route”: function(params) {  
…  
…  
//load my target page…  
…  
}

But we are facing an issue. Suppose I am on page “example.abc” and I click on this link of my page (“www.example.abc#!load/view/pid=123/false”).  
It redirects to my target page, but my URL changes to “example.abc#!load/view/pid%3D123/false”. My URL gets encoded.  
Now if I want to go back to my previous page, it takes 2 clicks of browser’s back button to do that.  
First, it redirects me to “example.abc#!load/view/pid=123/false” then on next click it redirects me to my previous page “example.abc”

I don’t want this encoded URL and want to solve this problem of back-button, please help me with any solution.

Any help would be appreciated

---

<div class="post-metadata">

**Author:** ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)\
**Post date:** [March 20, 2018, 7:15pm UTC](https://forums.bitovi.com/t/url-encoding-and-back-button-issue-in-canjs/826/2 "2018-03-20T19:15:59Z")

</div>

could you write out the url as encoded?

---

<div class="post-metadata">

**Author:** ![Prafull\_Dhadkar](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@Prafull\_Dhadkar](https://forums.bitovi.com/u/Prafull_Dhadkar)\
**Post date:** [March 21, 2018, 1:25am UTC](https://forums.bitovi.com/t/url-encoding-and-back-button-issue-in-canjs/826/3 "2018-03-21T01:25:15Z")

</div>

No, thats our requirement. We have to write our URL in this ("example.abc#!load/view/pid=123/false”) format only.

---

<div class="post-metadata">

**Author:** ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)\
**Post date:** [March 21, 2018, 2:30pm UTC](https://forums.bitovi.com/t/url-encoding-and-back-button-issue-in-canjs/826/4 "2018-03-21T14:30:58Z")

</div>

Here’s is where CanJS 1.1 serializes data into a url:

> <https://github.com/canjs/canjs/blob/ea63a8aa6718af9f2abe787cc8f6163188e531ea/route/route.js#L127>

There is a `encodeURIComponent` … you could try removing that, or at least avoiding it for `=`.

---

<div class="post-metadata">

**Author:** ![Prafull\_Dhadkar](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@Prafull\_Dhadkar](https://forums.bitovi.com/u/Prafull_Dhadkar)\
**Post date:** [March 22, 2018, 10:47am UTC](https://forums.bitovi.com/t/url-encoding-and-back-button-issue-in-canjs/826/5 "2018-03-22T10:47:33Z")

</div>

It works fine for first time, but when we reload the page, it changes the URL to “example.abc#!&load%2Fview%2Fpid=123%2Ffalse”.

Thus, browser doesn’t find any route for this url and it is redirected to home page.
