Open Flet opened 5 years ago
Could you explain a bit more about the changes, like why you were able to remove the different code paths for relative/absolute URLs, and why you're now passing href
in the opts object. Thanks!
I wanted to land this so rebased on master. Unfortunately, this was harder than I thought!
Since the current API allows passing any different combinations of options that is being feed right into http.request
it's very hard to keep the current API whilst moving to using URL
. I added two failing test cases that demonstrates two of the shortcomings.
I'm thinking that the best way forward is a new major release which explicitly states which options are valid, and only allows the new WHATWG URL
based ones:
Potentially also switching url
for href
:
For reference, here is the code to turn Node.js style opts into an url string, which we would need in order to pass it to as the base
parameter to new URL
:
https://github.com/nodejs/node/blob/4712472c0fa1fbd7df74541698659b85313ab576/lib/url.js#L614-L698
Here is a util function that turns an URL
into the expected request options, not too complicated:
edit: Hmm, I actually manage to get a version with every test passing, but there is a lot of code added in order for this, which I think that we should avoid...
You can see it here: https://github.com/feross/simple-get/compare/url-linusu-wip
The out-commented setOptionsFromUrl
is needed in order to support Node.js 10.0.0 - 10.8.0 😅
Closes #53
This also updates travis to use node versions 12 and 10 for tests.
node 8.x is at EOL starting December 2019.