Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Decode back-separator value before splitting it with separator #392

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

scottenock
Copy link
Contributor

The original implementation was splitting the received value before it then decoded the value. Because the value was URL encoded, the split function could not find the separator to successfully split. Adjusted the order of operations which fixes #388

  • Adjusted order of operations, ensuring we decode before splitting the value
  • Implemented test case to guard against this regression.

The original implementation was splitting the received value before it
then decoded the value. Because the value was URL encoded, the split
function could not find the seperator to successfully split. Adjusted
the order of operations which fixes sindresorhus#388
@scottenock scottenock changed the title FIX: Decode brack-seperator value before splitting it with seperator FIX: Decode brack-seperator value before splitting it with separator Sep 19, 2024
@scottenock scottenock changed the title FIX: Decode brack-seperator value before splitting it with separator FIX: Decode back-separator value before splitting it with separator Sep 19, 2024
@@ -215,6 +215,16 @@ test('query strings having a brackets+separator array and format option as `brac
}), {foo: ['']});
});

test('query strings having a brackets+separator array and format option as `bracket-separator` with a URL encoded value', t => {
t.deepEqual(queryString.parse('?testA%5B%5D=1&testB%5B%5D=a%2Cb%2Cc%2Cd%2Ce%2Cf&testC=true', {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer the string to be unencoded, and encode it before passing it to parse. This makes it possible to actually see what it contains when reading the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: comma separated arrays not parsed correctly from encoded url
2 participants