resources: Fix scss vs css import regexp
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 17 Mar 2020 07:03:25 +0000 (08:03 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 17 Mar 2020 07:03:25 +0000 (08:03 +0100)
Fixes #7063

resources/resource_transformers/tocss/scss/client.go
resources/resource_transformers/tocss/scss/client_test.go

index 85f6e525537f3dfdf5e57d9e6200fcf55f1b78d0..f3fe7921b0716f3373ff06b4638b081aefd23929 100644 (file)
@@ -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 \*\/).*`)
 )
 
index 8cc79136a5d8369d71c688e24f0d1948acab6bfc..f9adac2268e661b5698a2c693989c3c5315e6f12 100644 (file)
@@ -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)