Skip to main content

did_web_to_url

Function did_web_to_url 

Source
pub fn did_web_to_url(did: &str) -> Result<String>
Expand description

Derive the HTTPS DID-document URL for a did:web identifier, per the did:web spec (https://w3c-ccg.github.io/did-method-web/#read-resolve).

Two forms:

  • Bare host — did:web:{host} → https://{host}/.well-known/did.json. {host} may carry a percent-encoded port (%3A → :), e.g. did:web:localhost%3A8443 → https://localhost:8443/.well-known/did.json.
  • Path — did:web:{host}:{p1}:{p2}… → https://{host}/{p1}/{p2}…/did.json. The method-specific identifier’s colons separate path segments; within each segment, percent-encoding is decoded (so a literal colon in a segment is %3A). Only the first segment is the host (it alone may carry a port).

Returns Err if the input is not a did:web identifier or has an empty host.