diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-03-17 08:03:25 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-03-17 08:03:25 +0100 |
commit | c7b6d74e898c78da9f5e272e528ff9654206576e (patch) | |
tree | ed6bb8c84fe09759ad6646c3150e85b3cab814b3 | |
parent | 1a8af7d4f087256710ae0bdf504ed53c0c24a211 (diff) |
resources: Fix scss vs css import regexp
Fixes #7063
-rw-r--r-- | resources/resource_transformers/tocss/scss/client.go | 2 | ||||
-rw-r--r-- | resources/resource_transformers/tocss/scss/client_test.go | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/resources/resource_transformers/tocss/scss/client.go b/resources/resource_transformers/tocss/scss/client.go index 85f6e5255..f3fe7921b 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 8cc79136a..f9adac226 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) |