mirror of
				https://github.com/gradle/gradle-build-action.git
				synced 2025-10-31 23:28:55 +08:00 
			
		
		
		
	Replace spaces with underscore in job correlator
This commit is contained in:
		| @@ -171,5 +171,8 @@ function describeMatrix(matrixJson: string): string { | |||||||
| } | } | ||||||
|  |  | ||||||
| function sanitize(value: string): string { | function sanitize(value: string): string { | ||||||
|     return value.replace(/[^a-zA-Z0-9_-]/g, '').toLowerCase() |     return value | ||||||
|  |         .replace(/[^a-zA-Z0-9_-\s]/g, '') | ||||||
|  |         .replace(/\s+/g, '_') | ||||||
|  |         .toLowerCase() | ||||||
| } | } | ||||||
|   | |||||||
| @@ -4,12 +4,16 @@ describe('dependency-graph', () => { | |||||||
|     describe('constructs job correlator', () => { |     describe('constructs job correlator', () => { | ||||||
|         it('removes commas from workflow name', () => { |         it('removes commas from workflow name', () => { | ||||||
|             const id = dependencyGraph.constructJobCorrelator('Workflow, with,commas', 'jobid', '{}') |             const id = dependencyGraph.constructJobCorrelator('Workflow, with,commas', 'jobid', '{}') | ||||||
|             expect(id).toBe('workflowwithcommas-jobid') |             expect(id).toBe('workflow_withcommas-jobid') | ||||||
|         }) |         }) | ||||||
|         it('removes non word characters', () => { |         it('removes non word characters', () => { | ||||||
|             const id = dependencyGraph.constructJobCorrelator('Workflow!_with()characters', 'job-*id', '{"foo": "bar!@#$%^&*("}') |             const id = dependencyGraph.constructJobCorrelator('Workflow!_with()characters', 'job-*id', '{"foo": "bar!@#$%^&*("}') | ||||||
|             expect(id).toBe('workflow_withcharacters-job-id-bar') |             expect(id).toBe('workflow_withcharacters-job-id-bar') | ||||||
|         }) |         }) | ||||||
|  |         it('replaces spaces', () => { | ||||||
|  |             const id = dependencyGraph.constructJobCorrelator('Workflow !_ with () characters, and   spaces', 'job-*id', '{"foo": "bar!@#$%^&*("}') | ||||||
|  |             expect(id).toBe('workflow___with_characters_and_spaces-job-id-bar') | ||||||
|  |         }) | ||||||
|         it('without matrix', () => { |         it('without matrix', () => { | ||||||
|             const id = dependencyGraph.constructJobCorrelator('workflow', 'jobid', 'null') |             const id = dependencyGraph.constructJobCorrelator('workflow', 'jobid', 'null') | ||||||
|             expect(id).toBe('workflow-jobid') |             expect(id).toBe('workflow-jobid') | ||||||
| @@ -24,7 +28,7 @@ describe('dependency-graph', () => { | |||||||
|         }) |         }) | ||||||
|         it('with composite matrix value', () => { |         it('with composite matrix value', () => { | ||||||
|             const id = dependencyGraph.constructJobCorrelator('workflow', 'jobid', '{"os": "windows", "java-version": "21.1", "other": "Value, with COMMA"}') |             const id = dependencyGraph.constructJobCorrelator('workflow', 'jobid', '{"os": "windows", "java-version": "21.1", "other": "Value, with COMMA"}') | ||||||
|             expect(id).toBe('workflow-jobid-windows-211-valuewithcomma') |             expect(id).toBe('workflow-jobid-windows-211-value_with_comma') | ||||||
|         }) |         }) | ||||||
|     }) |     }) | ||||||
| }) | }) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user