Repository navigation
Replies: 1 comment 1 reply
|
Thanks for the clear scope. Non-ASCII paths are hard to read in the current log format, and keeping the wire-level value available in verbose output is the right constraint. I'd support a PR. Before writing it, a few details are worth settling in the design, because decoding for display is less trivial than it looks. Security: decoded output can contain control charactersPercent-decoding can produce characters that change how a log line is read or rendered:
Suggested rule: after decoding, replace C0/C1 control characters and newlines with their escaped percent form (or a visible placeholder), and keep the original encoded path for verbose output. This is more important than the readability gain, so I'd put it in the proposal, not leave it as an implementation detail. Ambiguity in decoding
Query stringsDecide whether the query string is also decoded. If it is, the same rules apply. If it isn't, the display will be inconsistent for the same character in the path and the query. I'd suggest decoding the path only, as the proposal currently states, and documenting that. Tests to addBeyond the cases in the proposal (Arabic, Japanese, emoji, malformed), include:
Practical noteRight-to-left scripts in a terminal can misalign columns and wrap differently from ASCII. This doesn't block the change, but it's worth testing the compact format in a real terminal with an Arabic path, since the goal is readability. If the sanitization rule above is included, I'd support the PR. |
Uh oh!
There was an error while loading. Please reload this page.
Goals
Non-Goals
Background
When running a Next.js application in development mode, request logs display
internationalized paths using percent-encoding.
For example, a route such as:
/dashboard/محطة-طنطا
is logged as:
GET /dashboard/%D9%85%D8%AD%D8%B7%D8%A9-%D8%B7%D9%86%D8%B7%D8%A7 200 in 99ms
This is technically correct and the request succeeds, but it significantly
reduces readability for developers working on applications where Arabic,
Japanese, or another non-ASCII language is the primary language.
ASCII paths remain readable, which makes the experience inconsistent across
languages.
The goal is to improve the developer experience of the development request
logger, not to change URL handling itself.
Proposal
Consider displaying a human-readable decoded pathname in development request
logs when the path contains percent-encoded Unicode characters.
For example:
GET /dashboard/محطة-طنطا 200 in 99ms
The original encoded request target should remain available through verbose or
debug logging when exact wire-level diagnostics are needed.
The implementation should:
I would be interested in contributing an implementation and tests if this direction is acceptable.
All reactions