Fix TechDocs Edit URL link when trailing slash not present

Signed-off-by: Kamil Markow <kamilmarkow@gmail.com>
This commit is contained in:
Kamil Markow
2024-08-05 13:19:31 -04:00
parent a577cdc9a9
commit 5cedd9f828
3 changed files with 7 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-techdocs-node': patch
---
Fix TechDocs Edit URL for nexted docs
@@ -115,6 +115,7 @@ describe('helpers', () => {
url | repo_url | edit_uri
${'https://github.com/backstage/backstage'} | ${'https://github.com/backstage/backstage'} | ${undefined}
${'https://github.com/backstage/backstage/tree/main/examples/techdocs/'} | ${'https://github.com/backstage/backstage/tree/main/examples/techdocs/'} | ${'https://github.com/backstage/backstage/edit/main/examples/techdocs/docs'}
${'https://github.com/backstage/backstage/tree/main/examples/techdocs'} | ${'https://github.com/backstage/backstage/tree/main/examples/techdocs'} | ${'https://github.com/backstage/backstage/edit/main/examples/techdocs/docs'}
${'https://github.com/backstage/backstage/tree/main/'} | ${'https://github.com/backstage/backstage/tree/main/'} | ${'https://github.com/backstage/backstage/edit/main/docs'}
${'https://gitlab.com/backstage/backstage'} | ${'https://gitlab.com/backstage/backstage'} | ${undefined}
${'https://gitlab.com/backstage/backstage/-/blob/main/examples/techdocs/'} | ${'https://gitlab.com/backstage/backstage/-/blob/main/examples/techdocs/'} | ${'https://gitlab.com/backstage/backstage/-/edit/main/examples/techdocs/docs'}
@@ -117,7 +117,7 @@ export const getRepoUrlFromLocationAnnotation = (
const sourceFolder = integration.resolveUrl({
url: `./${docsFolder}`,
base: target,
base: target.endsWith('/') ? target : `${target}/`,
});
return {
repo_url: target,