Skip to content

Commit c117b29

Browse files
authored
consider slashes while cleaning labels (#231)
fix prettier format check errors
1 parent 01a6551 commit c117b29

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/utilities/workflowAnnotationUtils.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@ describe('WorkflowAnnotationUtils', () => {
1111
)
1212
expect(cleanLabel('with⚒️emoji')).toEqual('withemoji')
1313
})
14+
it('should remove slashes from label', () => {
15+
expect(
16+
cleanLabel('Workflow Name / With Slashes / And Spaces')
17+
).toEqual('Workflow_Name_-_With_Slashes_-_And_Spaces')
18+
})
1419
})
1520
})

src/utilities/workflowAnnotationUtils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export function getWorkflowAnnotationKeyLabel(): string {
3737
* @returns cleaned label
3838
*/
3939
export function cleanLabel(label: string): string {
40-
const removedInvalidChars = label.replace(/[^-A-Za-z0-9_.]/gi, '')
40+
let removedInvalidChars = label
41+
.replace(/\s/gi, '_')
42+
.replace(/[\/\\\|]/gi, '-')
43+
.replace(/[^-A-Za-z0-9_.]/gi, '')
44+
4145
const regex = /([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]/
4246
return regex.exec(removedInvalidChars)[0] || ''
4347
}

0 commit comments

Comments
 (0)