Skip to content

querystring inconsistent behaviour #33910

@scucchiero

Description

@scucchiero

The module querystring presents odd behaviour and inconsistent across platforms.

On NodeJs v14.2 x86_64 GNU/Linux
Parsing an object with an empty array into a querystring yields & with no element.

const querystring = require('querystring')
> querystring.stringify({ a:2, b:[] })
'a=2&' // expected result --> a=2 or a=2&b= 

On Firefox 77.0.1 (64-bit)
Yet, when using the module in a react application with client side rendering the result is as follows:

import querystring from 'querystring'
> querystring.stringify({ a:2, b:[] }) // 'a=2'  

This issue can lead to some of the following malformed URLs which may fault some server parsers. (My experience was with WSGI server)

Metadata

Metadata

Assignees

No one assigned

    Labels

    querystringIssues and PRs related to the built-in querystring module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions