mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-30 09:19:27 +08:00
no longer using blank string for failed regex
This commit is contained in:
@@ -18,7 +18,7 @@ describe('WorkflowAnnotationUtils', () => {
|
|||||||
})
|
})
|
||||||
it('should return a blank string when regex fails (https://github.com/Azure/k8s-deploy/issues/266)', () => {
|
it('should return a blank string when regex fails (https://github.com/Azure/k8s-deploy/issues/266)', () => {
|
||||||
const label = '持续部署'
|
const label = '持续部署'
|
||||||
expect(cleanLabel(label)).toEqual('')
|
expect(cleanLabel(label)).toEqual('github-workflow-file')
|
||||||
|
|
||||||
let removedInvalidChars = label
|
let removedInvalidChars = label
|
||||||
.replace(/\s/gi, '_')
|
.replace(/\s/gi, '_')
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ export function cleanLabel(label: string): string {
|
|||||||
.replace(/[^-A-Za-z0-9_.]/gi, '')
|
.replace(/[^-A-Za-z0-9_.]/gi, '')
|
||||||
|
|
||||||
const regex = /([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]/
|
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]
|
return regexResult[0]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user