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: do not include context fields with null value #60

Merged
merged 3 commits into from
Feb 3, 2022

Conversation

ivarconr
Copy link
Member

@ivarconr ivarconr commented Jan 13, 2022

Currently we are looping over the context fields and add all of them with their respective value to as URL parameters. searchParams.append(..) will gladly convert null and undefined and convert these into string values, which is kind of surprising.

const urlWithQuery = new URL("https://getunleash.io");

// Using null
urlWithQuery.searchParams.append('a', null);
urlWithQuery.searchParams.has('a');
> true
urlWithQuery.searchParams.get('a');
> "null"

// using undefined
urlWithQuery.searchParams.append('b', undefined);
urlWithQuery.searchParams.has('b');
> true
urlWithQuery.searchParams.get('b');
> "undefined"

this PR adds filtering of context fields which has value null or undefined.

Copy link
Collaborator

@FredrikOseberg FredrikOseberg left a comment

Choose a reason for hiding this comment

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

LGTM

@ivarconr ivarconr merged commit 90bcef7 into main Feb 3, 2022
@ivarconr ivarconr deleted the fix/filter_contextValue_of_null branch February 3, 2022 10:07
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.

2 participants