shithub: hugo

Download patch

ref: c7b6d74e898c78da9f5e272e528ff9654206576e
parent: 1a8af7d4f087256710ae0bdf504ed53c0c24a211
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Tue Mar 17 04:03:25 EDT 2020

resources: Fix scss vs css import regexp

Fixes #7063

--- a/resources/resource_transformers/tocss/scss/client.go
+++ b/resources/resource_transformers/tocss/scss/client.go
@@ -76,7 +76,7 @@
 }
 
 var (
-	regularCSSImportTo   = regexp.MustCompile(`.*(@import "(.*.css)";).*`)
+	regularCSSImportTo   = regexp.MustCompile(`.*(@import "(.*\.css)";).*`)
 	regularCSSImportFrom = regexp.MustCompile(`.*(\/\* HUGO_IMPORT_START (.*) HUGO_IMPORT_END \*\/).*`)
 )
 
--- a/resources/resource_transformers/tocss/scss/client_test.go
+++ b/resources/resource_transformers/tocss/scss/client_test.go
@@ -28,6 +28,7 @@
 @import "regular.css";
 @import "moo";
 @import "another.css";
+@import "foo.scss";
 
 /* foo */`
 
@@ -37,7 +38,7 @@
 
 	res, replaced := replaceRegularImportsIn(scssWithImport)
 	c.Assert(replaced, qt.Equals, true)
-	c.Assert(res, qt.Equals, "\n\t\n@import \"moo\";\n/* HUGO_IMPORT_START regular.css HUGO_IMPORT_END */\n@import \"moo\";\n/* HUGO_IMPORT_START another.css HUGO_IMPORT_END */\n\n/* foo */")
+	c.Assert(res, qt.Equals, "\n\t\n@import \"moo\";\n/* HUGO_IMPORT_START regular.css HUGO_IMPORT_END */\n@import \"moo\";\n/* HUGO_IMPORT_START another.css HUGO_IMPORT_END */\n@import \"foo.scss\";\n\n/* foo */")
 
 	res2, replaced2 := replaceRegularImportsIn(scssWithoutImport)
 	c.Assert(replaced2, qt.Equals, false)