Don't drop path components of image URI

This commit is contained in:
Kitaiti Makoto 2021-02-25 11:01:47 +09:00
parent 33221d386e
commit 702aa11ecf
1 changed files with 4 additions and 5 deletions

View File

@ -12,7 +12,7 @@ use plume_common::{
}; };
use std::{ use std::{
fs::{self, DirBuilder}, fs::{self, DirBuilder},
path::{Path, PathBuf}, path::{self, Path, PathBuf},
}; };
use tracing::warn; use tracing::warn;
use url::Url; use url::Url;
@ -156,12 +156,11 @@ impl Media {
if self.is_remote { if self.is_remote {
Ok(self.remote_url.clone().unwrap_or_default()) Ok(self.remote_url.clone().unwrap_or_default())
} else { } else {
let p = Path::new(&self.file_path); let file_path = self.file_path.replace(path::MAIN_SEPARATOR, "/");
let filename: String = p.file_name().unwrap().to_str().unwrap().to_owned();
Ok(ap_url(&format!( Ok(ap_url(&format!(
"{}/static/media/{}", "{}/{}",
Instance::get_local()?.public_domain, Instance::get_local()?.public_domain,
&filename &file_path
))) )))
} }
} }