From 51323ad5a70020e288f7dd421ac002786c60009a Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Thu, 14 Sep 2023 10:01:09 -0500 Subject: [PATCH] Fix parsing bug --- project.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/project.go b/project.go index 41ac112..c09675b 100644 --- a/project.go +++ b/project.go @@ -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 {