Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

… for %2B
  • Loading branch information...
commit dd337ffa61ec946914b3d3a63c31584793dbcb36 1 parent 0684ae9
Konstantin Sykulev authored February 01, 2013
2  objektivity.js
@@ -10,7 +10,7 @@
10 10
 
11 11
     var unescape = function(s){
12 12
       if(!s){ return s; }
13  
-      return decodeURIComponent(s).replace(/\+/g, ' ');
  13
+      return decodeURIComponent(s.replace(/\+/g, '%20'));
14 14
     }
15 15
 
16 16
     var parseQuery = function(queryString, d){
3  test/objektivity_spec.js
@@ -9,6 +9,9 @@ describe("objektivity_spec", function(){
9 9
     it("should unespace %20", function(){
10 10
       expect(objektivity.unescape('a%20space')).toEqual('a space');
11 11
     });
  12
+    it("should unescape %2B", function(){
  13
+      expect(objektivity.unescape('a%2Bspace')).toEqual('a+space');
  14
+    });
12 15
     it("should unespace a URI escaped string", function(){
13 16
       expect(objektivity.unescape('q1%212%22%27w%245%267%2Fz8%29%3F%5C')).toEqual("q1!2\"'w$5&7/z8)?\\");
14 17
     });

0 notes on commit dd337ff

Please sign in to comment.
Something went wrong with that request. Please try again.