possible fix for third project section.
This commit is contained in:
parent
1fbe8579ba
commit
3b37b18581
12
main/main.go
12
main/main.go
@ -34,12 +34,15 @@ func MPE_IsProject(input *Payload) (projectnumber string, project_name string) {
|
|||||||
separated_path := strings.Split(split_path, "/") //turn this into an array (slice?) to parse
|
separated_path := strings.Split(split_path, "/") //turn this into an array (slice?) to parse
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
// iterate through the path_data map. We want to find all strings that start with a number.
|
// iterate through the path_data map. We want to find all strings that start with a number.
|
||||||
for _, value := range separated_path {
|
for keyvalue, value := range separated_path {
|
||||||
matched := project_regex.MatchString(value)
|
matched := project_regex.MatchString(value)
|
||||||
if matched {
|
// Possible Fix for Project 3rd Number ID.
|
||||||
|
ProjectSection := keyvalue == 2|3|4 // /shared<0>/N-Data<1>/<2>/<3>/<4>/<5>/<6>
|
||||||
|
|
||||||
|
if matched && ProjectSection {
|
||||||
// if we match the Regex above, write values to SB. This will give us a string like "73|10 Office Of Somone|153 HelpMe|002 Phase 2"
|
// if we match the Regex above, write values to SB. This will give us a string like "73|10 Office Of Somone|153 HelpMe|002 Phase 2"
|
||||||
|
|
||||||
sb.WriteString(value + "|")
|
sb.WriteString(value + "|") // add pipe separator
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// DoNothing
|
// DoNothing
|
||||||
@ -49,6 +52,7 @@ func MPE_IsProject(input *Payload) (projectnumber string, project_name string) {
|
|||||||
// now to assemble project number and project name from the resulting values...
|
// now to assemble project number and project name from the resulting values...
|
||||||
project_text := sb.String()
|
project_text := sb.String()
|
||||||
project_slice := strings.Split(project_text, "|")
|
project_slice := strings.Split(project_text, "|")
|
||||||
|
if strings.Count(project_text, "|") > 2 { // if more than 2 pipe | chars in string, could be a project.
|
||||||
// first value should be a digit, if not this can't be a project
|
// first value should be a digit, if not this can't be a project
|
||||||
isProject0, err := regexp.MatchString(`(^[0-9])`, project_slice[0])
|
isProject0, err := regexp.MatchString(`(^[0-9])`, project_slice[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -106,6 +110,8 @@ func MPE_IsProject(input *Payload) (projectnumber string, project_name string) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user