Skip to content

Commit 89cb4a5

Browse files
committed
Revert "feat: just point shields.io to the static url for it"
This reverts commit d1b1d0d.
1 parent d1b1d0d commit 89cb4a5

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/endpoints/mod_status_badge.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,14 @@ pub async fn status_badge(
6666
"shields/mod_downloads.svg",
6767
),
6868
};
69-
let svg_url = data.static_storage().asset_url(svg_path);
69+
let svg = data
70+
.static_storage()
71+
.read(svg_path)
72+
.await
73+
.map_err(|_| ApiError::InternalError("Failed to read status badge file".into()))?;
7074
let api_url = format!("{}/v1/mods/{}?abbreviate=true", data.app_url(), id);
7175
let mod_link = format!("{}/mods/{}", data.front_url(), id);
76+
let svg_data_url = format!("data:image/svg+xml;utf8,{}", urlencoding::encode_binary(&svg));
7277
let shields_url = format!(
7378
"https://img.shields.io/badge/dynamic/json?url={}&query={}&label={}&labelColor={}&color={}&link={}&style=plastic&logo={}",
7479
urlencoding::encode(&api_url),
@@ -77,7 +82,7 @@ pub async fn status_badge(
7782
urlencoding::encode(LABEL_COLOR),
7883
urlencoding::encode(STAT_COLOR),
7984
urlencoding::encode(&mod_link),
80-
urlencoding::encode(&svg_url)
85+
urlencoding::encode(&svg_data_url)
8186
);
8287
Ok(HttpResponse::Found()
8388
.append_header(("Location", shields_url))

0 commit comments

Comments
 (0)