Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sstephenson/prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
savetheclocktower committed Apr 4, 2013
2 parents faa0ba9 + 1d16dec commit e3d5200
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/prototype/lang/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,11 @@ Object.extend(String.prototype, (function() {
if ((pair = pair.split('='))[0]) {
var key = decodeURIComponent(pair.shift()),
value = pair.length > 1 ? pair.join('=') : pair[0];

if (value != undefined) value = decodeURIComponent(value);

if (value != undefined) {
value = value.gsub('+', ' ');
value = decodeURIComponent(value);
}

if (key in hash) {
if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
Expand Down
1 change: 1 addition & 0 deletions test/unit/hash_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ new Test.Unit.Runner({
this.assertEqual('a=A&b=B&c=C&d=D%23', $H(Fixtures.many).toQueryString());
this.assertEqual("a=b&c", $H(Fixtures.value_undefined).toQueryString());
this.assertEqual("a=b&c", $H("a=b&c".toQueryParams()).toQueryString());
this.assertEqual("a=b+d&c", $H("a=b+d&c".toQueryParams()).toQueryString());
this.assertEqual("a=b&c=", $H(Fixtures.value_null).toQueryString());
this.assertEqual("a=b&c=0", $H(Fixtures.value_zero).toQueryString());
this.assertEqual("color=r&color=g&color=b", $H(Fixtures.multiple).toQueryString());
Expand Down
3 changes: 2 additions & 1 deletion test/unit/string_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ new Test.Unit.Runner({
this.assertHashEqual({a:undefined}, 'a'.toQueryParams(), 'key without value');
this.assertHashEqual({a:'b'}, 'a=b&=c'.toQueryParams(), 'empty key');
this.assertHashEqual({a:'b', c:''}, 'a=b&c='.toQueryParams(), 'empty value');

this.assertHashEqual({a:' '}, 'a=++'.toQueryParams(), 'value of spaces');

this.assertHashEqual({'a b':'c', d:'e f', g:'h'},
'a%20b=c&d=e%20f&g=h'.toQueryParams(), 'proper decoding');
this.assertHashEqual({a:'b=c=d'}, 'a=b=c=d'.toQueryParams(), 'multiple equal signs');
Expand Down

0 comments on commit e3d5200

Please sign in to comment.