Skip to content

Commit 3d3b31e

Browse files
Degubirobjtede
andauthored
fix: svg files should be compressed (#3486)
* Fix svg files not being compressed * docs: update changelog --------- Co-authored-by: Rob Ede <robjtede@icloud.com>
1 parent 3147aac commit 3d3b31e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

actix-web/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Improve handling of non-UTF-8 header values in `Logger` middleware.
77
- Add `HttpServer::shutdown_signal()` method.
88
- Mark `HttpServer` as `#[must_use]`.
9+
- Allow SVG images to be compressed by the `Compress` middleware.
910
- Ignore `Host` header in `Host` guard when connection protocol is HTTP/2.
1011
- Re-export `mime` dependency.
1112
- Update `brotli` dependency to `8`.

actix-web/src/middleware/compress.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,10 @@ where
191191
None => true,
192192
Some(hdr) => {
193193
match hdr.to_str().ok().and_then(|hdr| hdr.parse::<Mime>().ok()) {
194-
Some(mime) if mime.type_().as_str() == "image" => false,
195-
Some(mime) if mime.type_().as_str() == "video" => false,
194+
Some(mime) if mime.type_() == mime::IMAGE => {
195+
matches!(mime.subtype(), mime::SVG)
196+
}
197+
Some(mime) if mime.type_() == mime::VIDEO => false,
196198
_ => true,
197199
}
198200
}

0 commit comments

Comments
 (0)