URL encoding and back-button issue in CanJS

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

could you write out the url as encoded?

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

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

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

1 Like

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.