-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
lib: use non-symbols in isURLInstance check #34622
Conversation
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.
Let's use this as part of the argument back to TC-39 that URL
really ought to be added to the language ;-) ... LGTM!
Does this mean that in electron there are two different implementations of URL floating around? |
Sadly, yes, but I believe the blink one is the one that's actually global. The Node.js one would still be accessible via |
@devsnek heh well "floating around" is a bit nebulous, but two can exist depending on where/how you're invoking Renderer example: const fs = require('fs');
const path = require('path');
const url1 = new URL('file://' + path.resolve('index.html'));
const url = require('url')
const url2 = new url.URL('file://' + path.resolve('index.html'));
console.log(url1) // Blink impl
console.log(url2) // Node.js impl will show: |
604cdfd
to
ab961ef
Compare
PR-URL: #34622 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Landed in 8825eb4. |
PR-URL: #34622 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: #34622 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: #34622 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: #34622 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This slightly changes the conditional used to determine whether or not something is a URL instance. Since Node.js adds symbols to the URL not specified by the WHATWG, those symbols are not present in other implementations (like Blink's) and therefore can cause false negatives. In Electron's renderer process, running e.g. this code:
would cause the following error:
To remedy this, I think we should instead switch on properties guaranteed to be present in all URL instances as specified by the WHATWG.
cc @jasnell
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes