Skip to content

Commit f0978ee

Browse files
authored
Rollup merge of #104404 - GuillaumeGomez:fix-missing-minification, r=notriddle
Fix missing minification for static files It's a fix for #101702. The problem was that `Path::ends_with` doesn't do what we thought it does: it checks if the entire item is the last path part, no just if the "path string" ends with the given argument. So instead, I just used the `extension()` method to get the information we want. cc `@jsha` r? `@notriddle` PS: Is it worth it to add a CI test to ensure that the minification was performed on JS and CSS files or not?
2 parents da2beab + e6baae5 commit f0978ee

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustdoc/html/static_files.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ impl StaticFile {
1919
}
2020

2121
pub(crate) fn minified(&self) -> Vec<u8> {
22-
if self.filename.ends_with(".css") {
22+
let extension = match self.filename.extension() {
23+
Some(e) => e,
24+
None => return self.bytes.to_owned(),
25+
};
26+
if extension == "css" {
2327
minifier::css::minify(str::from_utf8(self.bytes).unwrap()).unwrap().to_string().into()
24-
} else if self.filename.ends_with(".js") {
28+
} else if extension == "js" {
2529
minifier::js::minify(str::from_utf8(self.bytes).unwrap()).to_string().into()
2630
} else {
2731
self.bytes.to_owned()

0 commit comments

Comments
 (0)