-
Notifications
You must be signed in to change notification settings - Fork 209
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
Returned null in case of empty cookie value #196
Returned null in case of empty cookie value #196
Conversation
Thanks for the contribution! Unfortunately we can't verify the commit author(s): viralsinha <v***@p***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce.com Contributor License Agreement and this Pull Request will be revalidated. |
Hi @vsin12, would you be able to update the PR with a test? |
@ruoho : Sorry, but I didn't get you ? Do you want me to give a scenario while it was breaking or you want me to write a test to check my pr ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You wrote: Note: Either this fix, or CookieJar constructor needs to take SetCookieOptions too, as ignoreError is part of SetCookieOptions interface
ignoreError doesn't apply to storage: ignoreError - boolean - default false - silently ignore things like parse errors and invalid domains. Store errors aren't ignored by this option
-- so I'm not sure we need to do any more here, in terms of implementation. We might want to start a project to review ignoreError and its applications --- it might be better to have that apply globally, but we'd have to think that through.
In terms of this P/R; I think I'd like to see the change use validators, as suggested, and then have a simple unit test added that demonstrates the use-case (an empty cookie).
Co-authored-by: Andrew Waterman <[email protected]>
I think we still need a unit test for this fix. :) |
@vsin12 can you change this PR to allow edits from maintainers? I have a few changes I would like to push to this PR. |
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll discuss this today; I think we want to add a suggestion to return an error when presented with an empty cookie.
if(!validators.isNonEmptyString(cookie) && !validators.isObject(cookie) && ( cookie instanceof String && cookie.length == 0)) { | ||
return cb(null); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just looked at this in context, and I think this is fine. Will discuss today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see comment below; I think we may want an Error here.
this.callback | ||
); | ||
}, | ||
"results in a error being returned because of missing parameters": function(err, cookies) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't actually return an error, we are invoking the callback with a Null here. Should we invoke the CB with an Error()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. We may want to add error checking/throwing at some point, but that's probably in a major release.
Note: Either this fix, or CookieJar constructor needs to take SetCookieOptions too, as ignoreError is part of SetCookieOptions interface