Merge pull request #22473 from wss-cadenwheeler/azure-devops-backend-update-file-format-logic

Update extractPartsFromAsset function in azure-devops-backend to handle paths beginning with ".".
This commit is contained in:
Ben Lambert
2024-01-24 15:17:09 +01:00
committed by GitHub
3 changed files with 15 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-azure-devops-backend': patch
---
Fixed bug with `extractPartsFromAsset` that resulted in a leading `.` being removed from the path in an otherwise valid path (ex. `.assets/image.png`). The leading `.` will now only be moved for paths beginning with `./`.
@@ -235,6 +235,15 @@ describe('extractPartsFromAsset', () => {
ext: '.gif',
});
});
it('should return parts from asset with leading . without /', () => {
const result = extractPartsFromAsset('[Image 1](.images/sample-1.PNG)');
expect(result).toEqual({
label: 'Image 1',
path: '.images/sample-1',
ext: '.PNG',
});
});
});
describe('replaceReadme', () => {
@@ -325,7 +325,7 @@ export function extractPartsFromAsset(content: string): {
return {
ext,
label,
path: path.startsWith('.') ? path.substring(1, path.length) : path,
path: path.startsWith('./') ? path.substring(1, path.length) : path,
};
}