Improved encoding for url parameters that are objects or arrays #141
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I would like to ask to merge my changes to the master.
The problem I had with the library was that if I send some object as URL parameter to crossroads, it encodes every property of that object using encodeURI method. EncodeURI method is javascript method that does not encode characters like: ~!@#$&*()=:/,;?+' becuase it is used to encode whole url so for example '/' should not be encoded because it would change meaning of url. In crossroads it is used to encode just url parameters.
In my case, I have to put some parameters in url that contains # character but this character is reserved and has significant meaning in url so it needs to be encoded. Then, it is impossible to use crossroads for that case (because encodeURI does not encode #) unless I encode this parameter before sending it to crossroads. But when I encode # to %23, then crossroads encodes % again, ending with %2523 for # instead of %23.
It is possible to change the code (as followed in commit) to encode only keys and values of url parameters with use of javascript encodeURIComponent method that encodes more characters (all without ~!*()') and is supposed to encode url parameters. This method is standard method of javascript and solves problem of using special characters as url parameters.
Additionally, when I was building crossroads.js file from sources, crossroads.js.min has been deleted and it has not been created because some file to do this was missing. This is why this commit removes this crossroads.js.min file. It should be restored based on new crossroad.js.