Guard against falsy outputPath in eleventy htmlmin transform
Eleventy passes a falsy outputPath to transforms for templates rendered without a written file (e.g. permalink: false); calling .endsWith on it would throw. Skip minification in that case instead. Pre-existing latent issue surfaced by Copilot review on #2091.
This commit is contained in:
+2
-1
@@ -87,7 +87,8 @@ module.exports = function (eleventyConfig) {
|
||||
|
||||
// Minify HTML output
|
||||
eleventyConfig.addTransform('htmlmin', async function (content, outputPath) {
|
||||
if (!outputPath.endsWith('.html')) {
|
||||
// outputPath is falsy for templates rendered without a written file (e.g. permalink: false)
|
||||
if (!outputPath || !outputPath.endsWith('.html')) {
|
||||
return content
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user