Skip to content

Commit

Permalink
Always serve PNG favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Jan 12, 2024
1 parent 331dbb1 commit 2be5f6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ use {
axum::{
body,
extract::{Extension, Json, Path, Query},
headers::UserAgent,
http::{header, HeaderMap, HeaderValue, StatusCode, Uri},
response::{IntoResponse, Redirect, Response},
routing::get,
Router, TypedHeader,
Router,
},
axum_server::Handle,
brotli::Decompressor,
Expand Down Expand Up @@ -880,32 +879,12 @@ impl Server {
})
}

async fn favicon(user_agent: Option<TypedHeader<UserAgent>>) -> ServerResult<Response> {
if user_agent
.map(|user_agent| {
user_agent.as_str().contains("Safari/")
&& !user_agent.as_str().contains("Chrome/")
&& !user_agent.as_str().contains("Chromium/")
})
.unwrap_or_default()
{
Ok(
Self::static_asset(Path("/favicon.png".to_string()))
.await
.into_response(),
)
} else {
Ok(
(
[(
header::CONTENT_SECURITY_POLICY,
HeaderValue::from_static("default-src 'unsafe-inline'"),
)],
Self::static_asset(Path("/favicon.svg".to_string())).await?,
)
.into_response(),
)
}
async fn favicon() -> ServerResult<Response> {
Ok(
Self::static_asset(Path("/favicon.png".to_string()))
.await
.into_response(),
)
}

async fn feed(
Expand Down
Binary file modified static/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2be5f6a

Please sign in to comment.