File tree Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -122,14 +122,14 @@ var Form = {
122
122
accumulator = function ( result , key , values ) {
123
123
if ( ! Object . isArray ( values ) ) { values = [ values ] ; }
124
124
if ( ! values . length ) { return result ; }
125
- var encodedKey = encodeURIComponent ( key ) ;
125
+ // According to the spec, spaces should be '+' rather than '%20'.
126
+ var encodedKey = encodeURIComponent ( key ) . gsub ( / % 2 0 / , '+' ) ;
126
127
return result + ( result ? "&" : "" ) + values . map ( function ( value ) {
127
128
// Normalize newlines as \r\n because the HTML spec says newlines should
128
129
// be encoded as CRLFs.
129
130
value = value . gsub ( / ( \r ) ? \n / , '\r\n' ) ;
130
131
value = encodeURIComponent ( value ) ;
131
- // Likewise, according to the spec, spaces should be '+' rather than
132
- // '%20'.
132
+ // According to the spec, spaces should be '+' rather than '%20'.
133
133
value = value . gsub ( / % 2 0 / , '+' ) ;
134
134
return encodedKey + "=" + value ;
135
135
} ) . join ( "&" ) ;
Original file line number Diff line number Diff line change 118
118
</ form >
119
119
120
120
< form id ="form_with_inputs_needing_encoding " style ="display:none ">
121
- < input type ="hidden " name ="user[wristbands][][nickname] " id ="fine_1 " value ="Hässlich " />
121
+ < input type ="hidden " name ="user[wristbands][ ][nickname] " id ="fine_1 " value ="Hässlich " />
122
122
</ form >
123
123
124
124
< form id ="form_with_troublesome_input_names ">
Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ new Test.Unit.Runner({
301
301
} ,
302
302
303
303
testFormSerializeURIEncodesInputs : function ( ) {
304
- this . assertEqual ( "user%5Bwristbands%5D%5B%5D%5Bnickname%5D=H%C3%A4sslich" , $ ( 'form_with_inputs_needing_encoding' ) . serialize ( false ) ) ;
304
+ this . assertEqual ( "user%5Bwristbands%5D%5B+ %5D%5Bnickname%5D=H%C3%A4sslich" , $ ( 'form_with_inputs_needing_encoding' ) . serialize ( false ) ) ;
305
305
} ,
306
306
307
307
testFormMethodsOnExtendedElements : function ( ) {
You can’t perform that action at this time.
0 commit comments