-
Notifications
You must be signed in to change notification settings - Fork 234
Replace UrlEncode library with local implementation. #811
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
base: main
Are you sure you want to change the base?
Replace UrlEncode library with local implementation. #811
Conversation
…ncode include/effects/matrix/PatternSubscribers.h: Removed unused include of UrlEncode platformio: Remove external dependency of UrlEncode src/deviceconfig.cpp: If we don't have WiFi, we don't have a URL. src/network.cpp: Add textbook implementaion of urlEncode. effects/matrix/PatternSubscribers.h: Removed unused include of UrlEncode
rbergen
left a comment
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.
This may elicit a "yeah, right" from you, but I saw this one coming when we were discussing #788. :)
I have a couple of comments. I expect their phrasing will show I feel (much) more strongly about one than the other.
| DeviceConfig::ValidateResponse DeviceConfig::ValidateOpenWeatherAPIKey(const String &newOpenWeatherAPIKey) | ||
| { | ||
| #if ENABLE_WIFI | ||
| HTTPClient http; | ||
|
|
||
| String url = "http://api.openweathermap.org/data/2.5/weather?lat=0&lon=0&appid=" + urlEncode(newOpenWeatherAPIKey); | ||
|
|
||
| http.begin(url); | ||
|
|
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 think we should "if #ENABLE_WIFI" the whole ValidateOpenWeatherAPIKey() function, obviously including its declaration in deviceconfig.h. Anything calling it should also not be enabled when WIFI isn't.
(This may sound like nitpicking, but I just hate a function conditionally not doing what it clearly claims to do.)
|
|
||
| #include <Arduino.h> | ||
|
|
||
| String urlEncode(const String& str); |
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 suggest we add a comment to indicate where the definition lives, that not being UrlEncode.cpp.
Which is something I was actually going to challenge, but I can see the logic after thinking it through from a few different angles.
Description
Removed
UrlEncodethird-party dependency.include/UrlEncode.hproto and new (better) body insrc/network.cpp.Uses RFC 1738 style percent-encoding.
urlEncodefunction and its usage insrc/deviceconfig.cppwith#if ENABLE_WIFI. It may be possible to do better later, but we agree for now that without WIFI, there is no URL.UrlEncode.hfromPatternStocks.handPatternSubscribers.h.Contributing requirements
mainas the target branch.