Fix pictrs routing (#2407)

* SUGGESTED FIX TO PICTRS ROUTING 404 ERROR #2359

Removed slashes at "/image" routes.

* cargo fmt

Co-authored-by: Majid  <72635080+umamawme@users.noreply.github.com>
This commit is contained in:
Nutomic 2022-08-16 15:20:41 +00:00 committed by GitHub
parent f878151648
commit 583ceb2506
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View file

@ -125,7 +125,7 @@ pub(crate) async fn fetch_pictrs(
is_image_content_type(client, image_url).await?;
let fetch_url = format!(
"{}/image/download?url={}",
"{}image/download?url={}",
pictrs_config.url,
utf8_percent_encode(image_url.as_str(), NON_ALPHANUMERIC) // TODO this might not be needed
);

View file

@ -96,7 +96,7 @@ async fn upload(
};
let pictrs_config = context.settings().pictrs_config()?;
let image_url = format!("{}/image", pictrs_config.url);
let image_url = format!("{}image", pictrs_config.url);
let mut client_req = adapt_request(&req, &client, image_url);
@ -128,15 +128,12 @@ async fn full_res(
// If there are no query params, the URL is original
let pictrs_config = context.settings().pictrs_config()?;
let url = if params.format.is_none() && params.thumbnail.is_none() {
format!("{}/image/original/{}", pictrs_config.url, name,)
format!("{}image/original/{}", pictrs_config.url, name,)
} else {
// Use jpg as a default when none is given
let format = params.format.unwrap_or_else(|| "jpg".to_string());
let mut url = format!(
"{}/image/process.{}?src={}",
pictrs_config.url, format, name,
);
let mut url = format!("{}image/process.{}?src={}", pictrs_config.url, format, name,);
if let Some(size) = params.thumbnail {
url = format!("{}&thumbnail={}", url, size,);
@ -186,7 +183,7 @@ async fn delete(
let (token, file) = components.into_inner();
let pictrs_config = context.settings().pictrs_config()?;
let url = format!("{}/image/delete/{}/{}", pictrs_config.url, &token, &file);
let url = format!("{}image/delete/{}/{}", pictrs_config.url, &token, &file);
let mut client_req = adapt_request(&req, &client, url);