pub fn did_web_for_host(host: &str) -> StringExpand description
The did:web a hostname spells.
A hostname a person types carries the port they reach the server on. A
did:web carries one only for a bare loopback hostname — an atproto
client reads a port on anything else as a handle — so anywhere else the
port is dropped, which is also what the server’s own
Zone::service_did does. The colon that stays is percent-encoded,
the spelling AccountDid::parse reads back.
One function because seven callers had a copy of it, and a DID that disagrees with the one the server minted is a record written where nothing reads it.
use didbot_identity::did::did_web_for_host;
assert_eq!(did_web_for_host("kestrel.agents.localhost:3000"), "did:web:kestrel.agents.localhost");
assert_eq!(did_web_for_host("localhost:3000"), "did:web:localhost%3A3000");
assert_eq!(did_web_for_host("agents.example.com"), "did:web:agents.example.com");