Skip to content

Commit e3d5200

Browse files
Merge branch 'master' of github.com:sstephenson/prototype
2 parents faa0ba9 + 1d16dec commit e3d5200

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/prototype/lang/string.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,11 @@ Object.extend(String.prototype, (function() {
473473
if ((pair = pair.split('='))[0]) {
474474
var key = decodeURIComponent(pair.shift()),
475475
value = pair.length > 1 ? pair.join('=') : pair[0];
476-
477-
if (value != undefined) value = decodeURIComponent(value);
476+
477+
if (value != undefined) {
478+
value = value.gsub('+', ' ');
479+
value = decodeURIComponent(value);
480+
}
478481

479482
if (key in hash) {
480483
if (!Object.isArray(hash[key])) hash[key] = [hash[key]];

test/unit/hash_test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ new Test.Unit.Runner({
120120
this.assertEqual('a=A&b=B&c=C&d=D%23', $H(Fixtures.many).toQueryString());
121121
this.assertEqual("a=b&c", $H(Fixtures.value_undefined).toQueryString());
122122
this.assertEqual("a=b&c", $H("a=b&c".toQueryParams()).toQueryString());
123+
this.assertEqual("a=b+d&c", $H("a=b+d&c".toQueryParams()).toQueryString());
123124
this.assertEqual("a=b&c=", $H(Fixtures.value_null).toQueryString());
124125
this.assertEqual("a=b&c=0", $H(Fixtures.value_zero).toQueryString());
125126
this.assertEqual("color=r&color=g&color=b", $H(Fixtures.multiple).toQueryString());

test/unit/string_test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ new Test.Unit.Runner({
390390
this.assertHashEqual({a:undefined}, 'a'.toQueryParams(), 'key without value');
391391
this.assertHashEqual({a:'b'}, 'a=b&=c'.toQueryParams(), 'empty key');
392392
this.assertHashEqual({a:'b', c:''}, 'a=b&c='.toQueryParams(), 'empty value');
393-
393+
this.assertHashEqual({a:' '}, 'a=++'.toQueryParams(), 'value of spaces');
394+
394395
this.assertHashEqual({'a b':'c', d:'e f', g:'h'},
395396
'a%20b=c&d=e%20f&g=h'.toQueryParams(), 'proper decoding');
396397
this.assertHashEqual({a:'b=c=d'}, 'a=b=c=d'.toQueryParams(), 'multiple equal signs');

0 commit comments

Comments
 (0)