The path that turns into a host
A hostless URL changes meaning after it is serialized and parsed again.
What’s going wrong
A message router stores scheme, optional host and normalized path separately. A path beginning with two slashes becomes a host after serialization and reparsing. The same text has different meanings depending on structural context.
The first stdin line is scheme host path separated by spaces. Host - means absent; otherwise it is a nonempty ASCII alphanumeric/hyphen host. Schemes begin with an ASCII lowercase letter and contain lowercase letters, digits, + or -. Paths begin with /, contain only ASCII letters, digits, /, _, - and ., and are already normalized: no segment is exactly . or .. . At most 100 commands and 4096 total input bytes. PATH path, HOST host and SCHEME scheme replace one component; SHOW records an observation.
Canonical serialization with a host is scheme://host followed by path. Without a host it is scheme: followed by path, except a path starting // must have the guard /. inserted before it. Thus path //a becomes scheme:/.//a. The guard is serialization syntax, not part of the stored path. Reparse SHOW's serialized text using that rule and emit [serialized, reparsed_scheme, reparsed_host_or_dash, reparsed_path]. Print the JSON array of all SHOW observations. No commands means an empty array.
Preserve component identity across context changes and round trips. Do not change a stored path, always add a guard, or invent a host to make serialization easier.
Expected behavior
Maintain semantic round-trip identity across serialization and mutations that change whether bytes represent a host or path.
Reproduction
memo - //archive/log SHOW
[["memo:/.//archive/log","memo","-","//archive/log"]]
memo - /archive/log SHOW
[["memo:/archive/log","memo","-","/archive/log"]]
memo server /archive/log SHOW
[["memo://server/archive/log","memo","server","/archive/log"]]
Before you begin
- Rust strings, slices and loops
- Combine exact separators and contextual escaping into a multi-component invariant that must survive later reparsing.
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.