From 6f3d43ce060cf1d56f1c62a0101ac318a789eb05 Mon Sep 17 00:00:00 2001 From: Caden Wheeler Date: Tue, 23 Jan 2024 10:46:40 -0600 Subject: [PATCH 1/4] Updated extractPartsFromAsset in azure-devops-utils to handle file paths that being with only ".". Signed-off-by: Caden Wheeler --- .../src/utils/azure-devops-utils.test.ts | 9 +++++++++ .../azure-devops-backend/src/utils/azure-devops-utils.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/azure-devops-backend/src/utils/azure-devops-utils.test.ts b/plugins/azure-devops-backend/src/utils/azure-devops-utils.test.ts index 86a06b7b0b..c3e2cd1106 100644 --- a/plugins/azure-devops-backend/src/utils/azure-devops-utils.test.ts +++ b/plugins/azure-devops-backend/src/utils/azure-devops-utils.test.ts @@ -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', () => { diff --git a/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts b/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts index 7f5bf39ac4..d24b104bae 100644 --- a/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts +++ b/plugins/azure-devops-backend/src/utils/azure-devops-utils.ts @@ -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, }; } From 25bda45b026ddf50c92cfe188352b8e2f4c07d8d Mon Sep 17 00:00:00 2001 From: Caden Wheeler Date: Tue, 23 Jan 2024 10:50:11 -0600 Subject: [PATCH 2/4] Added changeset for @backstage/plugin-azure-devops-backend. Signed-off-by: Caden Wheeler --- .changeset/giant-suits-switch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/giant-suits-switch.md diff --git a/.changeset/giant-suits-switch.md b/.changeset/giant-suits-switch.md new file mode 100644 index 0000000000..3b5161a9f8 --- /dev/null +++ b/.changeset/giant-suits-switch.md @@ -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 "./". From 01b26056c17eb54b649774d727631cd2d24760bf Mon Sep 17 00:00:00 2001 From: Caden Wheeler Date: Wed, 24 Jan 2024 07:50:48 -0600 Subject: [PATCH 3/4] Updated changeset based on recommendation from PR review. Signed-off-by: Caden Wheeler --- .changeset/giant-suits-switch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/giant-suits-switch.md b/.changeset/giant-suits-switch.md index 3b5161a9f8..bf2724c2a5 100644 --- a/.changeset/giant-suits-switch.md +++ b/.changeset/giant-suits-switch.md @@ -2,4 +2,4 @@ '@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 "./". +Fixed bug with `extractPartsFromAsset` (used by the README card feature) 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 "./". From e633cedb0e97156d44f61155ceabec46c2878b28 Mon Sep 17 00:00:00 2001 From: Ben Lambert Date: Wed, 24 Jan 2024 15:05:33 +0100 Subject: [PATCH 4/4] Update giant-suits-switch.md Signed-off-by: Ben Lambert --- .changeset/giant-suits-switch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/giant-suits-switch.md b/.changeset/giant-suits-switch.md index bf2724c2a5..77d0e62c73 100644 --- a/.changeset/giant-suits-switch.md +++ b/.changeset/giant-suits-switch.md @@ -2,4 +2,4 @@ '@backstage/plugin-azure-devops-backend': patch --- -Fixed bug with `extractPartsFromAsset` (used by the README card feature) 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 "./". +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 `./`.