-
Notifications
You must be signed in to change notification settings - Fork 30k
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
url: show input in parse error message #11934
Conversation
a064947
to
790ff3e
Compare
Previous CI is unsuccessful. New CI: https://ci.nodejs.org/job/node-test-pull-request/6930/ |
+1 on this... tho I'm curious if we shouldn't also make it possible to access it programmatically. e.g. try {
new URL('test');
} catch (e) {
console.log(e.input);
} /cc @addaleax |
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.
LGTM with green CI
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.
LGTM.
src/node_url.cc
Outdated
String::NewFromUtf8(env->isolate(), | ||
input, | ||
v8::NewStringType::kNormal).ToLocalChecked(); | ||
(void)error_cb.As<Function>()->Call(context, recv, 2, argv); |
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.
I know it was there already, but using arraysize(argv)
should prevent the need for a hardcoded array length.
@@ -196,16 +188,12 @@ function onParsePathComplete(flags, protocol, username, password, | |||
|
|||
function onParseSearchComplete(flags, protocol, username, password, | |||
host, port, path, query, fragment) { | |||
if (flags & binding.URL_FLAGS_FAILED) | |||
return; |
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.
Just to make sure I’m not missing something – these are dropped because the on*Complete
functions are not called in the case of errors anymore, right?
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.
I'm also curious about it. Is that why the search setter doesn't need to have onParseError
in this case?
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.
Yes, the completion and the errors are handled in different callbacks, since it doesn't really make sense to pass all these parsed parts to an error callback anyway.
The setters are ignoring errors per the spec at the moment, so they don't have error callbacks.
Sure, why not? Making stuff programmatically accessible is always good. |
Use New CI: https://ci.nodejs.org/job/node-test-pull-request/6953/ |
This will need a rebase |
1a863ef
to
63b5a89
Compare
Rebased. Can anyone approved this before take a look again? Thanks! New CI: https://ci.nodejs.org/job/node-test-pull-request/6994/ |
Still LGTM |
PR-URL: #11934 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Landed in ee19e29 |
PR-URL: #11934 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Show the input in URL parse errors so it's easier to debug
Before
After
Also put the error handling in another callback of
binding.parse()
, if it is unspecified, nothing will be done.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
url
@nodejs/url