Skip to content

Commit

Permalink
no longer using blank string for failed regex
Browse files Browse the repository at this point in the history
  • Loading branch information
jaiveerk committed Dec 12, 2022
1 parent 86aca60 commit 0b82897
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/utilities/workflowAnnotationUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('WorkflowAnnotationUtils', () => {
})
it('should return a blank string when regex fails (https://github.com/Azure/k8s-deploy/issues/266)', () => {
const label = '持续部署'
expect(cleanLabel(label)).toEqual('')
expect(cleanLabel(label)).toEqual('github-workflow-file')

let removedInvalidChars = label
.replace(/\s/gi, '_')
Expand Down
4 changes: 3 additions & 1 deletion src/utilities/workflowAnnotationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export function cleanLabel(label: string): string {
.replace(/[^-A-Za-z0-9_.]/gi, '')

const regex = /([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]/
const regexResult = regex.exec(removedInvalidChars) || ['']
const regexResult = regex.exec(removedInvalidChars) || [
'github-workflow-file'
]
return regexResult[0]
}

0 comments on commit 0b82897

Please sign in to comment.