GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — proposal: WHATWG URL standard implementation by jasnell · Pull Request #28 · nodejs/node-eps
This repository was archived by the owner on Jul 31, 2018. It is now read-only.
Conversation
|
|
@nodejs/collaborators |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Perhaps we could raise interest in this by providing examples of failing tests. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@seishun ... https://github.com/nodejs/node/blob/master/test/known_issues/test-url-parse-conformance.js :-) We currently fail somewhere around 140+ of the test cases in the WhatWG set. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
+1 Considering that the browser are exposing the global I think it makes a whole bunch of sense. I'd be interested in helping out with this. Have you broken ground on implementation @jasnell? Can we borrow from implementations at all? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| The WhatWG URL Standard specifies updated syntax, parsing and serialization of | ||
| URLs as currently implemented by the main Web Browsers. The existing Node.js | ||
| `url` module parsing and serialization implementation currently does not support | ||
| the URL standard and fails to pass almost half of the parsing tests. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'll run the tests here shortly and update the number :-)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@thealphanerd ... yeah, I've got it mostly implemented already. The next step is to start running it through it's paces with tests and benchmarks and to find ways of optimizing the implementation. It's currently quite a bit slower than the existing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Regarding borrowing from other impls, it's entirely possible that we could borrow from chromes implementation. I'm not sure yet if theirs is a pure JS impl or not. I'll look into that. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Still considering those. They are easy enough to implement given the
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
There will also be other differences. For instance, I'm not sure if we need
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There is https://github.com/jsdom/whatwg-url cc @domenic |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yeah, I'm familiar with (and use) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Yep, that's @Sebmaster's most excellent work. It's not super optimized, but would be a good starting point. This thread is very exciting and I'm glad there is an appetite for the idea!! The idea of a global, the same as in browsers, is great. I think there are two separable problems here:
There are tests of the URL Standard at https://github.com/w3c/web-platform-tests/tree/master/url, and whatwg-url has a runner. The coverage is pretty reasonable; see web-platform-tests/wpt#3018 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Oh, that'd be very cool! I guess my only concern is that we weren't concerned with speed when writing it, so there is probably lots of low-hanging fruit for performance improvements. You'd also need to do a bit of work to decouple it from webidl-conversions and webidl2js. If you |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ok, I'll dig in and explore the whatwg-url internals and see what can be done reasonably. Before getting too deep into this I'd definitely like to get more +1's from collaborators tho. I'd really like to see this happen tho. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Definitely agree that it's worth separating these. Not sure about modifying the existing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Well, you can have a 👍 from me! More browser/server unity would be great. 😺 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
BTW, I like the idea of the global, since that's what browsers do, but I'd recommend not exposing it in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The only concern I would have with that, @Qard, is that if there is existing code that does |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This is not an argument for or against, but a request for more background. You've described what work you would like to do, and how you would do it — but I don't see much in the way of "why" we'd want to do this. What is not working about the status quo that we will rectify by adding a new global object? What value do Node users gain, concretely, from the URL object? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Maybe store it on |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@chrisdickinson personally I see quite a bit of benefit in minimizing the delta between node + the browser as far as utility API's like this are concerned. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@chrisdickinson ... the why is straightforward: Currently Node.js' URL parsing has a number of issues in terms of not following the standardized behavior implemented by browsers. Examples of those failures can be seen in the test case I referenced here. There are also differences in the Node.js provided API that are largely unnecessary. This work would give us an opportunity to not only provide more robust URL parsing, but to provide a unified, non-Node.js specific API. @Qard ... that's certainly a possibility |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
FWIW, looks like I mis-remembered the number of failures ;-) ... here's the exact count: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| ## Description | ||
|
|
||
| The WhatWG URL Standard specifies updated syntax, parsing and serialization of |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
s/WhatWG/WHATWG/g
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
acknowledged. Will fix that in the next update.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
My general dislike of constructors aside, I have to second @chrisdickinson's concern here. It's not clear to me why we'd want this as a global. Sure, that's how browsers implement it, but Node is not a browser, and browser APIs have historically been designed with a fundamentally different model in mind (namely, the lack of CommonJS). This proposal, in its current form, is starting to look like it'll drag Node in the direction of PHP - endlessly adding APIs and not really trying to enforce or encourage consistency. As it is, this will just further confuse users as to whether they should be As a separate question, how - if at all - does this cover the "insert object of URL components, receive stringified URL" usecase? EDIT: Further question: Are there any major concerns about just fixing the existing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Let's separate the concerns just a bit. We could implement this but not make it a global, and just have it accessible via the existing Second, on the point:
My goal here is to eventually be able to fully deprecate the existing
It would in-so-far as the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
That seems like a more workable solution to me. There would still likely be short-term user confusion while both APIs exist, however, so this would be something that'd require very clear documentation. I realize that you might've missed the question I added to my previous post later on - could you have a look at that suggestion as well?
I understand that, but I still don't really see the value in trying to bring the Node.js API in line with browser APIs, as opposed to just keeping it internally consistent (given that Node.js was designed with CommonJS in mind, and switching to globals for everything would be a step back). In the end, Node.js is its own environment, and I can't see how trying to reduce the API to the lowest common denominator would benefit usability.
That's probably what I mean, yeah - I'm thinking of something along the lines of the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
EPS proposal updated. /cc @nodejs/ctc |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| APIs. | ||
|
|
||
| Initially, the implementation would be introduced as an undocumented | ||
| experimental feature exposed via a new `URL` property in the `url` module. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
There's already a Url property that points to the old constructor/parser — this is likely to cause confusion. If we go down the route of supporting a new URL parser, we may as well expose it as a global. Code written for the browser expects it to be a global, we may as well avoid artificially increasing the delta between browser JS and server JS.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm all for it being a global.
On Jul 2, 2016 10:18 AM, "Chris Dickinson" [email protected] wrote:
In XXX-url.md
#28 (comment):
+## Description
+
+The WHATWG URL Standard specifies updated syntax, parsing and serialization of
+URLs as currently implemented by the main Web Browsers. The existing Node.js
+urlmodule parsing and serialization implementation currently does not support
+the URL standard and fails to pass 160 of the WHATWG URL parsing tests.
+
+This proposal is to implement the WHATWG URL Standard by modifying the existing
+urlmodule to provide an implementation of theURLobject and associated
+APIs. Doing so improves the robustness of URL parsing, provides consistency
+with browser js code, and can eventually allow the reduction of node.js specific
+APIs.
+
+Initially, the implementation would be introduced as an undocumented
+experimental feature exposed via a newURLproperty in theurlmodule.There's already a Url property that points to the old constructor/parser
— this is likely to cause confusion. If we go down the route of
supporting a new URL parser, we may as well expose it as a global. Code
written for the browser expects it to be a global, we may as well avoid
artificially increasing the delta between browser JS and server JS.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/nodejs/node-eps/pull/28/files/a0a892210e9fa20f684247dd58e838a9cd333df1#r69380482,
or mute the thread
https://github.com/notifications/unsubscribe/AAa2ecg3l3xtEecYClWoO40LgnxvIjUEks5qRp1pgaJpZM4IrtaC
.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm also fine with that. Already have encodeURI(), etc.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Putting this on the ctc-agenda as I believe it's ready for discussion/review. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Does npm rely on the parsing of urls with support for the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
There's a certain loss of functionality by using Taking the following excerpt from the WHATWG URL specification:
It seems that Even though Taking from RFC3986 we can see a simple generic way of parsing the URL that I think could be used at minimum to parse unfamiliar schemes:
Not to be rude, but check your own work first. Chrome has added an exception to Additionally, All this said, we should support other/unknown schemes properly with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It's already been clarified upthread that I was incorrect about special schemes. There are no special schemes besides file: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@domenic oop. sorry about that. completely glanced over that comment. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Adding git as a special scheme would be trivial if necessary. If necessary On Jul 13, 2016 10:13 PM, "Trevor Norris" [email protected] wrote:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
After further testing, git URLs are handled by this implementation without any problems whatsoever using the implementation in #28. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The CTC discussed this today and has decided to advance this to DRAFT status with the exception of the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@yorkie ... eventually, once the new URL object is no longer experimental, my goal is to replace use of the existing url.parse within the http module entirely. That's not going to be easy tho. It's going to take a long time. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Landed in f16f770 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.