NormalizeWorkflowName removes .md and .lock.yml extensions from workflow names. This is used to standardize workflow identifiers regardless of the file format. The function checks for extensions in order of specificity: 1. Removes .lock.yml extension (the compiled workflow format) 2. Removes .md ex
(name string)
| 27 | // NormalizeWorkflowName("weekly-research.lock.yml") // returns "weekly-research" |
| 28 | // NormalizeWorkflowName("my.workflow.md") // returns "my.workflow" |
| 29 | func NormalizeWorkflowName(name string) string { |
| 30 | // Remove .lock.yml extension first (longer extension) |
| 31 | if before, ok := strings.CutSuffix(name, ".lock.yml"); ok { |
| 32 | return before |
| 33 | } |
| 34 | |
| 35 | // Remove .md extension |
| 36 | if before, ok := strings.CutSuffix(name, ".md"); ok { |
| 37 | return before |
| 38 | } |
| 39 | |
| 40 | return name |
| 41 | } |
| 42 | |
| 43 | // NormalizeSafeOutputIdentifier converts dashes and periods to underscores for safe output |
| 44 | // identifiers. This standardizes identifier format to the internal underscore-separated |
no outgoing calls