-
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
util.format not printing % when there's multiple arguments #13665
Comments
This is probably due to #12407. |
/cc @nodejs/ctc |
/cc @jseijas |
In util.format, if a percent sign without a known type is encountered, just print it instead of silently ignoring it and the next character. Fixes: nodejs#13665
Possible fix: #13674 |
Ideally we should throw an error in such cases. The correct format string here is |
Yes, a throw would be ideal, but from my tests browsers don't throw on it either, so It'd be better to not throw for compat. I tested the case Firefox: Quite an interesting result in Safari (also present in WebKit Nightly). |
I can confirm the correct format of |
In util.format, if a percent sign without a known type is encountered, just print it instead of silently ignoring it and the next character. PR-URL: #13674 Fixes: #13665 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
In util.format, if a percent sign without a known type is encountered, just print it instead of silently ignoring it and the next character. PR-URL: #13674 Fixes: #13665 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
The following code in node 6.10.3 prints
percent: 10%, fraction: 0.1
In node 8.1.0 it prints
percent: 10 fraction: 0.1
. Notice the % is no longer printed.The following code gets back to the original node 6.10.3 output
Note the %% to print a single % in node 8
Also worth noting this problem doesn't happen if you are just printing one variable in node 8. The following code prints
percent: 10%
Should node 8 be formatting the same results as node 6? Or is this a functional change?
The text was updated successfully, but these errors were encountered: