-
Notifications
You must be signed in to change notification settings - Fork 484
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
Issue 250 encoded url param #290
base: main
Are you sure you want to change the base?
Conversation
Although I haven't worked on this recently, while opening the PR today, it occurred to me that there is an edge case that isn't handled and if this PR is accepted should be fixed. In particular if the user is providing paths relative to a We shouldn't "always decode" because encoded parameters might be destined for some further "upstream" purpose and decoding these parameters will break requests (same reason we stop decoding as soon as However this is easy to resolve as we can differentiate between the following:
I would need to check whether a leading slash is currently required on relative URLs or not. If it is not, that would be a breaking change. I can add this (and tests of course) and update the PR. But I won't bother making further changes unless I get an indication you are open to some version of this PR. Thanks! |
@willnorris - anything I can do to help move this forward? |
- URL encoding of remote urls is now supported (but still optional). - Options parameter is no longer optional. - You can pass empty/no-op options (`//http...` or `/x/http...` or `/0x0/http...`), - but not `/http...`. - Added more test cases.
e506a7b
to
1aa29ff
Compare
Was thinking about this again today. Regarding the baseURL comment above...
The docs example uses Even a leading slash doesn't help because you can imagine The solution is to never url-decode the url parameter when I've made this change and updated the tests. No more open issues from my side that should block this. @willnorris can you review the change when you have a chance? Okay if you don't want to incorporate this change, but would be happy for some feedback nonetheless. |
Codecov Report
@@ Coverage Diff @@
## main #290 +/- ##
==========================================
- Coverage 87.20% 86.42% -0.79%
==========================================
Files 6 6
Lines 508 523 +15
==========================================
+ Hits 443 452 +9
- Misses 35 38 +3
- Partials 30 33 +3
Continue to review full report at Codecov.
|
Hi @willnorris, Any chance you can give me some feedback on what we need to do to get url-encoding supported? I'm not a golang guy, so I won't take any critical feedback on this PR personally. Would just be happy for some feedback...or better, to be able to stop using my fork for production deployments. Thanks! |
Supporting url-encoded remote URLs as parameter
You can find more monologue about motivation (real world cases) and the implementation approach for this change in #250.
Summary
//http...
or/x/http...
or/0x0/http...
but not/http...
.Before this change, the code would attempt to URL-parse the first param and if that failed then assumed there were options present. That meant in the common case (options and url present) both the options and url would be attempted to be URL parsed in the logic. Now we expect parseable options to always be the first parameter.
The fact that options were optional (before this change) was not documented in the README, only in the code...so hoping this isn't a breaking change for most users. The fix is to add an empty/no-op option before the remote URL parameter (
//http...
or/x/http...
or/0x0/http...
).