diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-11-15 01:40:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-15 01:40:45 +0100 |
| commit | f0978eec014ddc076c00e1bb7ef50ca15dd9f6f7 (patch) | |
| tree | 57d28c03045f3b40af90911d85532eab522ae003 | |
| parent | da2beab3f67af6fd0e1ff11bd1007226800c08da (diff) | |
| parent | e6baae576c9b474d1946a1d0f98692c7a3e62549 (diff) | |
| download | rust-f0978eec014ddc076c00e1bb7ef50ca15dd9f6f7.tar.gz rust-f0978eec014ddc076c00e1bb7ef50ca15dd9f6f7.zip | |
Rollup merge of #104404 - GuillaumeGomez:fix-missing-minification, r=notriddle
Fix missing minification for static files It's a fix for https://github.com/rust-lang/rust/pull/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?
| -rw-r--r-- | src/librustdoc/html/static_files.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index afe920b7fa1..b4d4150cddb 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -19,9 +19,13 @@ impl StaticFile { } pub(crate) fn minified(&self) -> Vec<u8> { - if self.filename.ends_with(".css") { + let extension = match self.filename.extension() { + Some(e) => e, + None => return self.bytes.to_owned(), + }; + if extension == "css" { minifier::css::minify(str::from_utf8(self.bytes).unwrap()).unwrap().to_string().into() - } else if self.filename.ends_with(".js") { + } else if extension == "js" { minifier::js::minify(str::from_utf8(self.bytes).unwrap()).to_string().into() } else { self.bytes.to_owned() |
