Permalink
Browse files

Found a funky edge case with decodeURIComponent returning + for + and…

… for %2B
  • Loading branch information...
1 parent 0684ae9 commit dd337ffa61ec946914b3d3a63c31584793dbcb36 @ksykulev committed Feb 1, 2013
Showing with 4 additions and 1 deletion.
  1. +1 −1 objektivity.js
  2. +3 −0 test/objektivity_spec.js
View
@@ -10,7 +10,7 @@
var unescape = function(s){
if(!s){ return s; }
- return decodeURIComponent(s).replace(/\+/g, ' ');
+ return decodeURIComponent(s.replace(/\+/g, '%20'));
}
var parseQuery = function(queryString, d){
@@ -9,6 +9,9 @@ describe("objektivity_spec", function(){
it("should unespace %20", function(){
expect(objektivity.unescape('a%20space')).toEqual('a space');
});
+ it("should unescape %2B", function(){
+ expect(objektivity.unescape('a%2Bspace')).toEqual('a+space');
+ });
it("should unespace a URI escaped string", function(){
expect(objektivity.unescape('q1%212%22%27w%245%267%2Fz8%29%3F%5C')).toEqual("q1!2\"'w$5&7/z8)?\\");
});

0 comments on commit dd337ff

Please sign in to comment.