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(util): Explicitly check for undefined value in getHeaderValues #23

Closed
wants to merge 2 commits into from

Conversation

gurkohli
Copy link

@gurkohli gurkohli commented Jun 15, 2022

Fix for improbable-eng/grpc-web#1109

getHeaderValues does a truthy check with the value that is returned by headers.get

  const getValue = headers.get(key);
  if (getValue && typeof getValue === "string") {

If getValue is an empty string, it fails this check. The empty string is returned by the function and the logic throws an error when .forEach is done on it. Fix is to correctly verify for non existence of the value and return an empty array in that case

Changes

Updated getHeaderValue to first check for the existence using headers.has. If the value does not exist, return empty array. Removed the truthy check afterwords

Verification

Tested by creating a build, using that build in @improbable/grpc-web client and further using that. The issue improbable-eng/grpc-web#1109 goes away

@gurkohli
Copy link
Author

Would you be able to review this or know the best person to review this @MarcusLongmuir ?

fix(util): Explicitly check for undefined value in getHeaderValue
This pull request was closed.
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.

1 participant