Fix: not greedy match the frontmatter in postcss parser (#4457)

This commit is contained in:
Elias Meire authored and Lucas Duailibe committed 2018-05-10 13:50:19 -03:00
1 parent b504e79113
commit 2f5c00ad18
3 files changed
+41 -1

No files matched your search

+1 -1
View File
@@ -439,7 +439,7 @@ function parseNestedCSS(node) {
function parseWithParser(parser, text) {
let result;
const frontMatterMatches = text.match(/^---(\n[\s\S]*)?\n---/);
const frontMatterMatches = text.match(/^---(\n[\s\S]*?)?\n---/);
const frontMatter = frontMatterMatches && frontMatterMatches[0];
const normalizedText = frontMatter ? text.substr(frontMatter.length) : text;
@@ -53,6 +53,33 @@ a {
`;
exports[`malformed-2.css 1`] = `
---
foo: bar
---
a {
color:blue
}
---
.b {
color:red
}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
foo: bar
---
a {
color: blue;
}
--- .b {
color: red;
}
`;
exports[`only_comments.css 1`] = `
---
# comment 1
+13
View File
@@ -0,0 +1,13 @@
---
foo: bar
---
a {
color:blue
}
---
.b {
color:red
}