mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 05:25:40 +09:00
fix(media-proxy): rasterize svg responses (#1298)
This commit is contained in:
1 parent
bbd24c4016
commit
e8bb455502
7 files changed
+317
-194
No files matched your search
@@ -20,12 +20,16 @@ pub struct OutputSelection {
|
||||
pub fn is_output_format_supported(ext: AssetExtension) -> bool {
|
||||
!matches!(
|
||||
ext,
|
||||
AssetExtension::Avif | AssetExtension::Heic | AssetExtension::Heif | AssetExtension::Jxl
|
||||
AssetExtension::Avif
|
||||
| AssetExtension::Heic
|
||||
| AssetExtension::Heif
|
||||
| AssetExtension::Jxl
|
||||
| AssetExtension::Svg
|
||||
)
|
||||
}
|
||||
|
||||
pub fn can_encode_to(ext: AssetExtension) -> bool {
|
||||
is_output_format_supported(ext) && ext != AssetExtension::Svg
|
||||
is_output_format_supported(ext)
|
||||
}
|
||||
|
||||
pub fn coerce_unsupported_format(ext: AssetExtension) -> AssetExtension {
|
||||
@@ -80,6 +84,18 @@ mod tests {
|
||||
assert_eq!("url-coerced", r.reason);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn svg_url_extension_coerces_to_webp() {
|
||||
let r = select_url_variant(Input {
|
||||
kind: AssetKind::Avatar,
|
||||
original: AssetExtension::Svg,
|
||||
requested_size: Some(128),
|
||||
manual_format_override: None,
|
||||
});
|
||||
assert_eq!(AssetExtension::Webp, r.format);
|
||||
assert_eq!("url-coerced", r.reason);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn manual_query_format_wins_over_url_extension() {
|
||||
let r = select_url_variant(Input {
|
||||
|
||||
Reference in new issue
Block a user