diff --git a/src/client.js b/src/client.js index 209912e12..419f225aa 100644 --- a/src/client.js +++ b/src/client.js @@ -128,7 +128,7 @@ function serialize(obj) { function pushEncodedKeyValuePair(pairs, key, val) { if (val === undefined) return; if (val === null) { - pairs.push(encodeURIComponent(key)); + pairs.push(encodeURI(key)); return; } @@ -142,7 +142,7 @@ function pushEncodedKeyValuePair(pairs, key, val) { pushEncodedKeyValuePair(pairs, `${key}[${subkey}]`, val[subkey]); } } else { - pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(val)); + pairs.push(encodeURI(key) + '=' + encodeURIComponent(val)); } } diff --git a/test/client/serialize.js b/test/client/serialize.js index 77e8f9e8b..831287cfd 100644 --- a/test/client/serialize.js +++ b/test/client/serialize.js @@ -35,6 +35,7 @@ describe('request.serializeObject()', () => { serialize({ name: '&tj&' }, 'name=%26tj%26'); serialize({ '&name&': 'tj' }, '%26name%26=tj'); serialize({ hello: '`test`' }, 'hello=%60test%60'); + serialize({ $hello: 'test' }, '$hello=test'); }); });