From e6baae576c9b474d1946a1d0f98692c7a3e62549 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 14 Nov 2022 15:14:54 +0100 Subject: [PATCH] Fix missing minification for static files --- src/librustdoc/html/static_files.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index afe920b7fa1e0..b4d4150cddbb8 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 { - 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()