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

Force header values in the request to be a string. #449

Merged
merged 1 commit into from
Feb 22, 2019

Conversation

pope
Copy link
Contributor

@pope pope commented Feb 22, 2019

This will allow for dynamic header values to be set in the config by
simply having an object with a toString method.

This will allow for dynamic header values to be set in the config by
simply having an object with a `toString` method.
@@ -134,7 +134,7 @@ spf.nav.request.send = function(url, opt_options) {
var value = configHeaders[key];
// Treat undefined and null values as equivalent to an empty string.
// Note that undefined == null.
headers[key] = (value == null) ? '' : value;
headers[key] = (value == null) ? '' : String(value);
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason not to use value.toString()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could. But this works as well. Any reason to use toString() over String()?

Copy link
Member

Choose a reason for hiding this comment

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

Whatever the JS equivalent is of the phrase "Pythonic". JSonic 🤔?
I just tend to see methods used rather than constructors.

In any case, not sure how active this project is and whether @nicksay wants to accept updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicksay is out until March. I talked to @DavidCPhillips and he seemed OK with the change.

With respect to JSonic - just look to this code base. String(value) happens a couple of times. toString does not appear to be the convention.

Copy link
Member

Choose a reason for hiding this comment

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

fwiw: (null).toString() -> error. String(null) -> "null". Same for undefined and perhaps other obnoxious things.

@DavidCPhillips DavidCPhillips merged commit 59cab19 into youtube:master Feb 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 participants