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
This u.query.a = [1, 2, 3]; creates a=1&a=2&a=3 while the correct is a[0]=1&a[1]=2&a[2]=3
The currently generated URL can lead to query overload, which depends on the server (apache, lighttpd or Microsoft) understand differently. While the second one is the correct array GET structure.
In languages where associative array exists, the following is also valid:
For u.query.a = ['key1' => 1, 'key5' => 2, 'key3' => 3]; represented as a[key1]=1&a[key5]=2&a[key3]=3, this is most probably represented in JS as an object like u.query.a = {"key1": 1, "key5": 2, "key3": 3};.
Also, servers support multidimensional array/objects, which's not supported here. u.query.a = [1, [2, 5], 3]; as a[0]=1&a[1][0]=2&a[1][1]=5&a[2]=3 u.query.a = {"key1": 1, "key5": [2, 5], "key3": 3}; as a[key1]=1&a[key5][0]=2&a[key5][1]=5&a[key3]=3 u.query.a = {"key1": 1, "key5": {"key1": 2, "key6": 5}, "key3": 3}; as a[key1]=1&a[key5][key1]=2&a[key5][key6]=5&a[key3]=3
The text was updated successfully, but these errors were encountered:
golddragon007
changed the title
Array url is encoded/decoded in the wrong way
Array/object url is encoded/decoded in the wrong way
Mar 12, 2021
This
u.query.a = [1, 2, 3];
createsa=1&a=2&a=3
while the correct isa[0]=1&a[1]=2&a[2]=3
The currently generated URL can lead to query overload, which depends on the server (apache, lighttpd or Microsoft) understand differently. While the second one is the correct array GET structure.
In languages where associative array exists, the following is also valid:
For
u.query.a = ['key1' => 1, 'key5' => 2, 'key3' => 3];
represented asa[key1]=1&a[key5]=2&a[key3]=3
, this is most probably represented in JS as an object likeu.query.a = {"key1": 1, "key5": 2, "key3": 3};
.Also, servers support multidimensional array/objects, which's not supported here.
u.query.a = [1, [2, 5], 3];
asa[0]=1&a[1][0]=2&a[1][1]=5&a[2]=3
u.query.a = {"key1": 1, "key5": [2, 5], "key3": 3};
asa[key1]=1&a[key5][0]=2&a[key5][1]=5&a[key3]=3
u.query.a = {"key1": 1, "key5": {"key1": 2, "key6": 5}, "key3": 3};
asa[key1]=1&a[key5][key1]=2&a[key5][key6]=5&a[key3]=3
The text was updated successfully, but these errors were encountered: