diff --git a/plugins/azure-devops/src/utils/getAnnotationValuesFromEntity.test.ts b/plugins/azure-devops/src/utils/getAnnotationValuesFromEntity.test.ts index 1f7ce53bde..c13dc526d8 100644 --- a/plugins/azure-devops/src/utils/getAnnotationValuesFromEntity.test.ts +++ b/plugins/azure-devops/src/utils/getAnnotationValuesFromEntity.test.ts @@ -334,7 +334,7 @@ describe('getAnnotationValuesFromEntity', () => { }); }); - describe('with more then expected slashes', () => { + describe('host-org with more then expected slashes', () => { it('should throw incorrect format error', () => { const entity: Entity = { apiVersion: 'backstage.io/v1alpha1', @@ -357,4 +357,28 @@ describe('getAnnotationValuesFromEntity', () => { ); }); }); + + describe('project-repo with more then expected slashes', () => { + it('should throw incorrect format error', () => { + const entity: Entity = { + apiVersion: 'backstage.io/v1alpha1', + kind: 'Component', + metadata: { + namespace: 'default', + name: 'project-repo', + annotations: { + 'dev.azure.com/project-repo': 'project/another/repo/final', + }, + }, + }; + + const test = () => { + return getAnnotationValuesFromEntity(entity); + }; + + expect(test).toThrow( + 'Invalid value for annotation "dev.azure.com/project-repo"; expected format is: /, found: "project/another/repo/final"', + ); + }); + }); }); diff --git a/plugins/azure-devops/src/utils/getAnnotationValuesFromEntity.ts b/plugins/azure-devops/src/utils/getAnnotationValuesFromEntity.ts index bf0b038c95..83091fb155 100644 --- a/plugins/azure-devops/src/utils/getAnnotationValuesFromEntity.ts +++ b/plugins/azure-devops/src/utils/getAnnotationValuesFromEntity.ts @@ -68,7 +68,7 @@ function getProjectRepo(annotations?: Record): { return { project: undefined, repo: undefined }; } - if (annotation.includes('/')) { + if (annotation.split('/').length === 2) { const [project, repo] = annotation.split('/'); if (project && repo) { return { project, repo };