fix: put bac protocol in urls

This commit is contained in:
əlemi 2024-03-26 01:02:48 +01:00
parent 6a050c0bb4
commit 13f99532fe
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 6 additions and 2 deletions

View file

@ -55,7 +55,7 @@ pub async fn view(State(ctx): State<Context>) -> Result<Json<serde_json::Value>,
.set_public_key(Node::object( .set_public_key(Node::object(
serde_json::Value::new_object() serde_json::Value::new_object()
.set_id(Some(&url!(ctx, "#main-key"))) .set_id(Some(&url!(ctx, "#main-key")))
.set_owner(Some(ctx.base())) .set_owner(Some(&url!(ctx, "")))
.set_public_key_pem(&ctx.app().public_key) .set_public_key_pem(&ctx.app().public_key)
)) ))
.ld_context() .ld_context()

View file

@ -19,7 +19,7 @@ struct ContextInner {
#[macro_export] #[macro_export]
macro_rules! url { macro_rules! url {
($ctx:expr, $($args: tt)*) => { ($ctx:expr, $($args: tt)*) => {
format!("{}{}", $ctx.base(), format!($($args)*)) format!("{}{}{}", $ctx.protocol(), $ctx.base(), format!($($args)*))
}; };
} }
@ -86,6 +86,10 @@ impl Context {
&self.0.domain &self.0.domain
} }
pub fn protocol(&self) -> &str {
&self.0.protocol
}
pub fn uri(&self, entity: &str, id: String) -> String { pub fn uri(&self, entity: &str, id: String) -> String {
if id.starts_with("http") { id } else { if id.starts_with("http") { id } else {
format!("{}{}/{}/{}", self.0.protocol, self.0.domain, entity, id) format!("{}{}/{}/{}", self.0.protocol, self.0.domain, entity, id)