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()