Updated extractPartsFromAsset in azure-devops-utils to handle file paths that being with only ".".

Signed-off-by: Caden Wheeler <cawheeler@webstaurantstore.com>
This commit is contained in:
Caden Wheeler
2024-01-23 10:46:40 -06:00
parent 5bdb001063
commit 6f3d43ce06
2 changed files with 10 additions and 1 deletions
@@ -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,
};
}