Closed digitalartcrew closed 4 years ago
Hi, this is expected behavior because of a workaround for a bug/limitation of the AngularJS $location
service regarding slash encoding/decoding.
This workaround changes the path
parameter type so it encodes slashes as ~2F
instead of %2F
). Because of that arbitrarily chosen escape sequence, tildes also have to be treated specially, thus they are quoted as ~~
. If you do not like this behavior, you can use a different parameter type, such as string
by changing your state's URL from /state/list/:param
to /state/list/{param:string}
.
Other things worth noting:
Hope this helps!
Just a note in my case (using "angular-ui-router": "^0.3.1") I had to change the state's URL from /state/list/:param to /state/list/{param:any} and it worked perfectly. Thanks for the guidance on this issue.
This issue tracker is for Bug Reports and Feature Requests only.
Please direct requests for help to StackOverflow. See http://bit.ly/UIR-SOF for details.
This is a (check one box):
My version of UI-Router is: (type version) 0.3.1
Bug Report
Current Behavior:
When setting a param with the value of a tilde
~
it is not percent ended and it duplicates in the url. For some example, I were to setmyParam=~abc
in the url it would display aspathName?myParam=~~abc
and when using the param to make a subsequent query it would use the incorrect value.Expected Behavior:
I expect when I set the param that it will be percent-encoded in url and href as
/pathName?myParam=%7Eabc
Link to Plunker or stackblitz that reproduces the issue:
https://plnkr.co/edit/zhNFUDPPQeEMMo50Zt19
https://stackoverflow.com/questions/59205703/how-do-i-prevent-angularjs-routing-from-encoding-a-url-parameter-with-a-tilde