The caret that changes the path
A component encoder applies different URL policies correctly except for one missing path character.
What’s going wrong
A URL-normalization test differs from the reference browser only for paths containing a caret. The same caret is legal unescaped in this exercise's query component.
Input is mode path or query on the first line and one even-length hexadecimal byte string on the second (- means empty). At most 4096 decoded bytes. For both modes percent-encode bytes 00..20, 7f..ff, and the ASCII bytes double-quote, #, <, >. Path mode additionally encodes ?, ^, backtick, { and }. Query mode leaves those five bytes unchanged. Other bytes, including / and %, remain unchanged; do not decode or normalize existing percent text.
Emit the resulting ASCII string, using uppercase hex in escapes. Process UTF-8 as its original bytes. This is a defined component-encoding policy, not full URL parsing. Fix the path discrepancy without broadening the query policy.
Expected behavior
Apply context-specific byte transformations without changing the policy of neighboring protocol components.
Reproduction
path 2f615e62
/a%5Eb
path 2f646f63732f66696c652e747874
/docs/file.txt
query 713d615e62
q=a^b
Before you begin
- Rust strings, slices and loops
- Use the previous separator lessons to distinguish bytes that are syntax in one component but data in another.
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.