Fix: not greedy match the frontmatter in postcss parser (#4457)
This commit is contained in:
1 parent
b504e79113
commit
2f5c00ad18
3 files changed
+41
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
foo: bar
|
||||
---
|
||||
|
||||
a {
|
||||
color:blue
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
.b {
|
||||
color:red
|
||||
}
|
||||
Reference in new issue
Block a user