Skip to content
Permalink
Browse files

resources: Fix scss vs css import regexp

Fixes #7063
  • Loading branch information
bep committed Mar 17, 2020
1 parent 1a8af7d commit c7b6d74e898c78da9f5e272e528ff9654206576e
@@ -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 \*\/).*`)
)

@@ -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)

0 comments on commit c7b6d74

Please sign in to comment.
You can’t perform that action at this time.