Empty Query parameters are not correctly parsed into the req.query object.
Investigative informationProvide the steps required to reproduce the problem:
Run the following extremely useful query to JSON function:
index.js:
module.exports = async function (context, req) { return { status: 200, body: {...req.query}, headers: { 'content-type': 'application/json', }, }; }
function.json:
{ "bindings": [ { "authLevel": "anonymous", "type": "httpTrigger", "direction": "in", "name": "req", "methods": [ "get" ] }, { "type": "http", "direction": "out", "name": "$return" } ] }
{"test1":"success"}
.&test2
to the query string in the browser. It should show an object that includes the test1
, and `test2' keys. It actually does not include test2.&test3=
to the query string in the browser. It should show an object that includes the test1
, test2
, and test3
keys. It actually does not include test2
or test3
.I expect the query parsing behavior to match the queryParams behavior of the built in URL object - each key in the query shows up in the output, defaulting to an empty string.
Actual behaviorThe query object only includes keys that have values other than the empty string.
Known workaroundsCurrently I have to do the following:
const url = new URL(req.url); const correctQuery = url.queryParams;Related information
Provide any related information
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4