Fix parsing some issue template names
YAML parsing sometimes gets sabotaged by asterisks that follow the end of frontmatter (`---`). We now scope YAML parsing to only frontmatter and we don't pass any contents that follow.
This commit is contained in:
parent
4ef468c19a
commit
8b9e7df705
2 changed files with 4 additions and 5 deletions
|
|
@ -66,11 +66,12 @@ mainLoop:
|
|||
// ExtractName returns the name of the template from YAML front-matter
|
||||
func ExtractName(filePath string) string {
|
||||
contents, err := ioutil.ReadFile(filePath)
|
||||
if err == nil && detectFrontmatter(contents)[0] == 0 {
|
||||
frontmatterBoundaries := detectFrontmatter(contents)
|
||||
if err == nil && frontmatterBoundaries[0] == 0 {
|
||||
templateData := struct {
|
||||
Name string
|
||||
}{}
|
||||
if err := yaml.Unmarshal(contents, &templateData); err == nil && templateData.Name != "" {
|
||||
if err := yaml.Unmarshal(contents[0:frontmatterBoundaries[1]], &templateData); err == nil && templateData.Name != "" {
|
||||
return templateData.Name
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,9 +148,7 @@ name: Bug Report
|
|||
about: This is how you report bugs
|
||||
---
|
||||
|
||||
Template contents
|
||||
---
|
||||
More of template
|
||||
**Template contents**
|
||||
`,
|
||||
args: args{
|
||||
filePath: tmpfile.Name(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue