Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rot13maxi committed Nov 21, 2023
1 parent 384bc68 commit c634afb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/page_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ pub(crate) struct PageConfig {
impl Default for PageConfig {
fn default() -> Self {
Self {
chain: Chain::Mainnet,
domain: None,
index_sats: false,
content_security_policy_origin: None,
chain: Chain::Mainnet,
domain: None,
index_sats: false,
content_security_policy_origin: None,
}
}
}
}
17 changes: 10 additions & 7 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Server {
.content_security_policy_origin
.clone()
.or_else(|| acme_domains.first().cloned())
.or(None);
.or(None);

let page_config = Arc::new(PageConfig {
chain: options.chain(),
Expand Down Expand Up @@ -1056,7 +1056,7 @@ impl Server {
let csp = format!("default-src {origin}/content/ {origin}/blockheight {origin}/blockhash {origin}/blockhash/ {origin}/blocktime 'unsafe-eval' 'unsafe-inline' data: blob:");
headers.insert(
header::CONTENT_SECURITY_POLICY,
HeaderValue::from_str(&csp).map_err(|err| ServerError::Internal(Error::from(err)))?
HeaderValue::from_str(&csp).map_err(|err| ServerError::Internal(Error::from(err)))?,
);
}
}
Expand Down Expand Up @@ -3172,10 +3172,13 @@ mod tests {
AcceptEncoding::default(),
&PageConfig::default(),
)
.unwrap()
.unwrap();
.unwrap()
.unwrap();

assert_eq!(headers["content-security-policy"], HeaderValue::from_static("default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob:"));
assert_eq!(
headers["content-security-policy"],
HeaderValue::from_static("default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob:")
);
}

#[test]
Expand All @@ -3188,8 +3191,8 @@ mod tests {
..Default::default()
},
)
.unwrap()
.unwrap();
.unwrap()
.unwrap();

assert_eq!(headers["content-security-policy"], HeaderValue::from_static("default-src https://ordinals.com/content/ https://ordinals.com/blockheight https://ordinals.com/blockhash https://ordinals.com/blockhash/ https://ordinals.com/blocktime 'unsafe-eval' 'unsafe-inline' data: blob:"));
}
Expand Down

0 comments on commit c634afb

Please sign in to comment.