diff --git a/src/utilities/workflowAnnotationUtils.test.ts b/src/utilities/workflowAnnotationUtils.test.ts index 5fc55475..bed2bd1a 100644 --- a/src/utilities/workflowAnnotationUtils.test.ts +++ b/src/utilities/workflowAnnotationUtils.test.ts @@ -11,5 +11,10 @@ describe('WorkflowAnnotationUtils', () => { ) expect(cleanLabel('with⚒️emoji')).toEqual('withemoji') }) + it('should remove slashes from label', () => { + expect( + cleanLabel('Workflow Name / With Slashes / And Spaces') + ).toEqual('Workflow_Name_-_With_Slashes_-_And_Spaces') + }) }) }) diff --git a/src/utilities/workflowAnnotationUtils.ts b/src/utilities/workflowAnnotationUtils.ts index 8d304594..248b53f3 100644 --- a/src/utilities/workflowAnnotationUtils.ts +++ b/src/utilities/workflowAnnotationUtils.ts @@ -37,7 +37,11 @@ export function getWorkflowAnnotationKeyLabel(): string { * @returns cleaned label */ export function cleanLabel(label: string): string { - const removedInvalidChars = label.replace(/[^-A-Za-z0-9_.]/gi, '') + let removedInvalidChars = label + .replace(/\s/gi, '_') + .replace(/[\/\\\|]/gi, '-') + .replace(/[^-A-Za-z0-9_.]/gi, '') + const regex = /([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]/ return regex.exec(removedInvalidChars)[0] || '' }