Skip to content

Commit

Permalink
fix replacing all "%20" with "+" in $.param()
Browse files Browse the repository at this point in the history
  • Loading branch information
StuPig authored and mislav committed Sep 23, 2012
1 parent ee77d69 commit 3c11adf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,6 @@
var params = []
params.add = function(k, v){ this.push(escape(k) + '=' + escape(v)) }
serialize(params, obj, traditional)
return params.join('&').replace('%20', '+')
return params.join('&').replace(/%20/g, '+')
}
})(Zepto)
5 changes: 5 additions & 0 deletions test/ajax.html
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,11 @@ <h1>Zepto Ajax unit tests</h1>
t.assertEqual("equation%5B1%5D=bananas%2Bpeaches%3Dsmoothie", result)
},

testParamSpaces: function(t) {
var result = $.param({ "foo bar": "baz kuux" })
t.assertEqual("foo+bar=baz+kuux", result)
},

testParamComplex: function(t) {
var data = {
a: ['b', 'c', { d:'e', f:['g','h'] }]
Expand Down

0 comments on commit 3c11adf

Please sign in to comment.