You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wish to propose a change in behaviour in the following situation, created by ticket #27:
const params = new URLSearchParams({ q: ['a,b', 'c'] });
console.log(params.toString());
Chrome, Firefox, and Safari (all as installed on my machine) currently output q=a%2Cb%2Cc.
I think this should be considered non-ideal, and propose two alternatives:
the output instead be q=a%2Cb,c i.e. only commas within a multi-value parameter get percent-encoded, and literal commas are used to delineate array members. Servers can now distinguish between requests generated by {q: ['a,b', 'c']} from those generated by {q: ['a,b,c']} or {q: ['a', 'b', 'c']} or {q: 'a,b,c'} (though the latter two would still be indistinguishable). This distinction might be meaningful to the server. Or, better still;
the output instead be q=a,b&q=c. Passing an ordered map to the URLSearchParams prohibits the possibility of using the same key twice. If it's value is an array and the presence of that array causes the key to be repeated in the URL, then the facility of a generating a URL where a key appears multiple times can be restored to this constructor. Some webserver frameworks only keep the last value of plain keys, and would require the key be given as {'q[]': [values...]} for an array to be reconstructed on the server-side, which is fine. That would only be possible with this second option.
Both of these seem better than the status quo, with my preference being for the latter.
The text was updated successfully, but these errors were encountered:
I wish to propose a change in behaviour in the following situation, created by ticket #27:
Chrome, Firefox, and Safari (all as installed on my machine) currently output
q=a%2Cb%2Cc
.I think this should be considered non-ideal, and propose two alternatives:
the output instead be
q=a%2Cb,c
i.e. only commas within a multi-value parameter get percent-encoded, and literal commas are used to delineate array members. Servers can now distinguish between requests generated by{q: ['a,b', 'c']}
from those generated by{q: ['a,b,c']}
or{q: ['a', 'b', 'c']}
or{q: 'a,b,c'}
(though the latter two would still be indistinguishable). This distinction might be meaningful to the server. Or, better still;the output instead be
q=a,b&q=c
. Passing an ordered map to the URLSearchParams prohibits the possibility of using the same key twice. If it's value is an array and the presence of that array causes the key to be repeated in the URL, then the facility of a generating a URL where a key appears multiple times can be restored to this constructor. Some webserver frameworks only keep the last value of plain keys, and would require the key be given as{'q[]': [values...]}
for an array to be reconstructed on the server-side, which is fine. That would only be possible with this second option.Both of these seem better than the status quo, with my preference being for the latter.
The text was updated successfully, but these errors were encountered: