resources: Fix scss vs css import regexp

Fixes #7063
This commit is contained in:
Bjørn Erik Pedersen 2020-03-17 08:03:25 +01:00
parent 1a8af7d4f0
commit c7b6d74e89
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
2 changed files with 3 additions and 2 deletions

View 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 \*\/).*`)
)

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