Skip to main content

document_url

Function document_url 

Source
pub fn document_url(did: &Did) -> Result<Url, WebError>
Available on crate feature did-web and (crate features did-jwk or did-key or did-web) only.
Expand description

The URL of the document of did (the Read operation’s URL construction): https://host[:port]/.well-known/did.json for a bare domain, else https://host[:port]/<segments>/did.json.

§Errors

WebError::InvalidDid when did is not a did:web, names an IP address, has a malformed port, or has an empty, . or .. path segment, percent-encoded or not.

§Examples

use identity_kit::did::Did;
use identity_kit::methods::web::document_url;

let url = document_url(&Did::parse("did:web:example.com")?)?;
assert_eq!(url.as_str(), "https://example.com/.well-known/did.json");

let url = document_url(&Did::parse("did:web:example.com%3A3000:user:alice")?)?;
assert_eq!(url.as_str(), "https://example.com:3000/user/alice/did.json");