From 702aa11ecf9bebfd619428edea13ec3aaeb7fa87 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Thu, 25 Feb 2021 11:01:47 +0900 Subject: [PATCH] Don't drop path components of image URI --- plume-models/src/medias.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plume-models/src/medias.rs b/plume-models/src/medias.rs index ba477657..db5a86ab 100644 --- a/plume-models/src/medias.rs +++ b/plume-models/src/medias.rs @@ -12,7 +12,7 @@ use plume_common::{ }; use std::{ fs::{self, DirBuilder}, - path::{Path, PathBuf}, + path::{self, Path, PathBuf}, }; use tracing::warn; use url::Url; @@ -156,12 +156,11 @@ impl Media { if self.is_remote { Ok(self.remote_url.clone().unwrap_or_default()) } else { - let p = Path::new(&self.file_path); - let filename: String = p.file_name().unwrap().to_str().unwrap().to_owned(); + let file_path = self.file_path.replace(path::MAIN_SEPARATOR, "/"); Ok(ap_url(&format!( - "{}/static/media/{}", + "{}/{}", Instance::get_local()?.public_domain, - &filename + &file_path ))) } }