Skip to content

Commit 7694c63

Browse files
Fix mime type for js files
1 parent 71b5fb3 commit 7694c63

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

src/web/page/templates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ impl IconType {
311311
IconType::Brand => font_awesome_as_a_crate::Type::Brands,
312312
};
313313

314-
let icon_file_string = font_awesome_as_a_crate::svg(type_, &icon_name[..]).unwrap_or("");
314+
let icon_file_string = font_awesome_as_a_crate::svg(type_, icon_name).unwrap_or("");
315315

316316
let mut classes = vec!["fa-svg"];
317317
if fw {

src/web/page/web_page.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use super::TemplateData;
21
use crate::web::{csp::Csp, error::AxumNope};
32
use axum::{
43
body::Body,
@@ -25,7 +24,7 @@ macro_rules! impl_axum_webpage {
2524
$(, cpu_intensive_rendering = $cpu_intensive_rendering:expr)?
2625
$(,)?
2726
) => {
28-
impl crate::web::page::web_page::AddCspNonce for $page {
27+
impl $crate::web::page::web_page::AddCspNonce for $page {
2928
fn render_with_csp_nonce(&mut self, csp_nonce: String) -> rinja::Result<String> {
3029
self.csp_nonce = csp_nonce;
3130
self.render()
@@ -103,7 +102,6 @@ pub(crate) struct DelayedTemplateRender {
103102

104103
fn render_response(
105104
mut response: AxumResponse,
106-
bla: Arc<TemplateData>,
107105
csp_nonce: String,
108106
) -> BoxFuture<'static, AxumResponse> {
109107
async move {
@@ -138,7 +136,6 @@ fn render_response(
138136
} else {
139137
return render_response(
140138
AxumNope::InternalError(err.into()).into_response(),
141-
bla,
142139
csp_nonce,
143140
)
144141
.await;
@@ -159,12 +156,6 @@ fn render_response(
159156
}
160157

161158
pub(crate) async fn render_templates_middleware(req: AxumRequest, next: Next) -> AxumResponse {
162-
let templates: Arc<TemplateData> = req
163-
.extensions()
164-
.get::<Arc<TemplateData>>()
165-
.expect("template data request extension not found")
166-
.clone();
167-
168159
let csp_nonce = req
169160
.extensions()
170161
.get::<Arc<Csp>>()
@@ -174,5 +165,5 @@ pub(crate) async fn render_templates_middleware(req: AxumRequest, next: Next) ->
174165

175166
let response = next.run(req).await;
176167

177-
render_response(response, templates, csp_nonce).await
168+
render_response(response, csp_nonce).await
178169
}

src/web/releases.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,12 +1657,13 @@ mod tests {
16571657
wrapper(|env| {
16581658
let web = env.frontend();
16591659

1660-
let empty_data = format!("data: [{}]", vec!["0"; 30].join(","));
1660+
let empty_data = format!("data: [{}]", vec!["0"; 30].join(", "));
16611661

16621662
// no data / only zeros without releases
16631663
let response = web.get("/releases/activity/").send()?;
16641664
assert!(response.status().is_success());
1665-
assert_eq!(response.text().unwrap().matches(&empty_data).count(), 2);
1665+
let text = response.text();
1666+
assert_eq!(text.unwrap().matches(&empty_data).count(), 2);
16661667

16671668
env.fake_release().name("some_random_crate").create()?;
16681669
env.fake_release()
@@ -1690,9 +1691,9 @@ mod tests {
16901691
assert!(response.status().is_success());
16911692
let text = response.text().unwrap();
16921693
// counts contain both releases
1693-
assert!(text.contains(&format!("data: [{},2]", vec!["0"; 29].join(","))));
1694+
assert!(text.contains(&format!("data: [{}, 2]", vec!["0"; 29].join(", "))));
16941695
// failures only one
1695-
assert!(text.contains(&format!("data: [{},1]", vec!["0"; 29].join(","))));
1696+
assert!(text.contains(&format!("data: [{}, 1]", vec!["0"; 29].join(", "))));
16961697

16971698
Ok(())
16981699
})

src/web/statics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ fn build_static_css_response(content: &'static str) -> impl IntoResponse {
2626
}
2727

2828
async fn set_needed_static_headers(req: Request, next: Next) -> Response {
29-
let is_opensearch_xml = req.uri().path().ends_with("/opensearch.xml");
29+
let req_path = req.uri().path();
30+
let is_opensearch_xml = req_path.ends_with("/opensearch.xml");
3031

3132
let mut response = next.run(req).await;
3233

0 commit comments

Comments
 (0)