Fix parsing bug

This commit is contained in:
Brian Buller 2023-09-14 10:01:09 -05:00
parent 3728b9b14f
commit 51323ad5a7
1 changed files with 15 additions and 5 deletions

View File

@ -29,12 +29,10 @@ func ParseProject(text string) (*Project, error) {
//parts := strings.Fields(project.Original)
var pIdx int
for pIdx = range parts {
if len(parts[pIdx]) > 0 {
if parts[pIdx][0] == '^' {
break
}
project.Name = project.Name + " " + parts[pIdx]
if partIsSpecial(parts[pIdx]) {
break
}
project.Name = project.Name + " " + parts[pIdx]
}
project.Name = strings.TrimSpace(project.Name)
parts = parts[pIdx:]
@ -81,6 +79,18 @@ func ParseProject(text string) (*Project, error) {
return &project, err
}
func partIsSpecial(pt string) bool {
if len(pt) == 0 {
return false
}
switch pt[0] {
case '^', '~', '#', '@', '+':
return true
default:
return false
}
}
// getParts parses the text from text pulling out each part.
// By default it splits on spaces, the only exception is if we find a double-quote
func getParts(text string) []string {