-
-
Notifications
You must be signed in to change notification settings - Fork 941
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
WHATWG-URL support #228
Comments
Please include a more comprehensive issue description. What exactly would you like to see changed in Got? |
This library does not support |
Can you provide a code example of how you would like to use URL with Got? |
const url = new URL("http://domain/")
got(url).then() |
I'd love to help out with this one. Let's see if we can sketch a clear picture of the problem that needs solving. Got currently expects an URL to be a simple string (which it parses), or a node http request options object. In the future, node devs will ideally rely on
I'll also do a naive implementation and see what breaks. Let me know if there's anything I missed and should consider before opening a PR! /cc @stevenvachon since you are clearly knowledgeable in the matter and might feel like giving me some pointers 😄. |
This may not be necessary, as |
I see. The URL object looks just like the options object http has expected since forever (forgive me not digging around to find out how far back this works). So that would just leave not manipulating the URL object in a way that breaks it. I'll look into it! Thanks @stevenvachon! |
Such support has been implemented in v7.x and, like all other The main difference |
Alright, I played around with it a little. If I understand you correctly. Got would ideally be using This means:
Sounds like I can get to work 😄. |
Started work on this, after a bunch of contemplating I realised I probably misunderstood something. @stevenvachon could you please verify all you meant earlier was for got to stop breaking I'm quite sure it's what you meant. I'll continue work assuming this is true 😄. Sorry for taking so long to understand what you were after. In case you also meant for got to start supporting |
I've been writing universal-url for seamless Node v4+ and browser support. |
I don't think it's essential enough to add more dependencies for Node.js 4 support, but happy to add support for WHATWG URL when a user is on Node.js 8. |
Maybe I'll write a "has-whatwg-url" or similar package. Though, since this will likely be input only, isurl may only be necessary. |
I've seen isomorphic-url! Nice to see you're building libs to help out the ecosystem. I agree with sindre that it seems a bit much to start supporting I would be happy to add v8+ support for I guess for now I'm moving on to another issue, thanks you two 😄. |
@alextes for what reason do you need |
Sorry, that's what I meant @stevenvachon. I confused terms. |
Still lost on what you guys would like to see implementation wise. I can imagine:
|
You could do both. #1 would require a new module ("hasurl") that I could publish with code pulled from isomorphic-url. #2 would require isurl for situations where |
@stevenvachon 🙌 |
@stevenvachon please check out the PR. You can probably explain why it's not okay to serialize and parse whatwg-url. I have the feeling I'm still not fully grasping your / whatwg's intentions here. |
My original intent was to drop the use of Regarding your PR, I don't see why a re-parse is necessary when you can abstract the mismatching properties with variables: let auth;
if (!isURL(url)) {
url = urlParseLax(url);
auth = url.auth;
}
else {
auth = `${url.username}:${url.password}`;
if (auth === ':') auth = '';
} |
URL
/ whatwg-url is the future.The text was updated successfully, but these errors were encountered: