Skip to content

Commit

Permalink
Found a funky edge case with decodeURIComponent returning + for + and…
Browse files Browse the repository at this point in the history
… for %2B
  • Loading branch information
ksykulev committed Feb 1, 2013
1 parent 0684ae9 commit dd337ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion objektivity.js
Expand Up @@ -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){
Expand Down
3 changes: 3 additions & 0 deletions test/objektivity_spec.js
Expand Up @@ -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)?\\");
});
Expand Down

0 comments on commit dd337ff

Please sign in to comment.