From: Bjørn Erik Pedersen Date: Tue, 17 Mar 2020 07:03:25 +0000 (+0100) Subject: resources: Fix scss vs css import regexp X-Git-Tag: v0.68.0~14 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c7b6d74e898c78da9f5e272e528ff9654206576e;p=brevno-suite%2Fhugo resources: Fix scss vs css import regexp Fixes #7063 --- diff --git a/resources/resource_transformers/tocss/scss/client.go b/resources/resource_transformers/tocss/scss/client.go index 85f6e525..f3fe7921 100644 --- a/resources/resource_transformers/tocss/scss/client.go +++ b/resources/resource_transformers/tocss/scss/client.go @@ -76,7 +76,7 @@ func DecodeOptions(m map[string]interface{}) (opts Options, err error) { } var ( - regularCSSImportTo = regexp.MustCompile(`.*(@import "(.*.css)";).*`) + regularCSSImportTo = regexp.MustCompile(`.*(@import "(.*\.css)";).*`) regularCSSImportFrom = regexp.MustCompile(`.*(\/\* HUGO_IMPORT_START (.*) HUGO_IMPORT_END \*\/).*`) ) diff --git a/resources/resource_transformers/tocss/scss/client_test.go b/resources/resource_transformers/tocss/scss/client_test.go index 8cc79136..f9adac22 100644 --- a/resources/resource_transformers/tocss/scss/client_test.go +++ b/resources/resource_transformers/tocss/scss/client_test.go @@ -28,6 +28,7 @@ func TestReplaceRegularCSSImports(t *testing.T) { @import "regular.css"; @import "moo"; @import "another.css"; +@import "foo.scss"; /* foo */` @@ -37,7 +38,7 @@ func TestReplaceRegularCSSImports(t *testing.T) { 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)