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: URLEncodedFormDecoder ignores empty value when decoding Array #2584

Merged
merged 6 commits into from
Mar 31, 2021

Conversation

t-ae
Copy link
Contributor

@t-ae t-ae commented Mar 17, 2021

When URLEncodedFormDecoder decodes array[]=a&array[]=&array[]=b&array[]=, empty values are ignored and we get incorrect result ["a", "b"].
After this change the result will be ["a", "", "b", ""].

})
self.values = try values.flatMap { value in
try value.asUrlEncoded().split(omittingEmptySubsequences: false) {
configuration.arraySeparators.contains($0)
Copy link
Member

Choose a reason for hiding this comment

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

LGTM, but I've got I feel like we should change this to:
split(omittingEmptySubsequences: false, whereSeparator: configuration.arraySeparators.contains)

@siemensikkema siemensikkema added the semver-patch Internal changes only label Mar 23, 2021
Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

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

LGTM

@0xTim 0xTim merged commit 73d5795 into vapor:main Mar 31, 2021
@VaporBot
Copy link
Contributor

These changes are now available in 4.41.10

@t-ae t-ae deleted the fix-url-encoded-form-array branch April 1, 2021 07:38
ky1vstar added a commit to ky1vstar/URLEncodedFormKit that referenced this pull request Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch Internal changes only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants