fix(techdocsStorageClient): properly construct baseUrls
Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-techdocs': patch
|
||||
---
|
||||
|
||||
Fix issue where assets weren't being fetched from the correct URL path for doc URLs without trailing slashes
|
||||
@@ -59,6 +59,12 @@ describe('TechDocsStorageClient', () => {
|
||||
).resolves.toEqual(
|
||||
`${mockBaseUrl}/static/docs/${mockEntity.namespace}/${mockEntity.kind}/${mockEntity.name}/test.js`,
|
||||
);
|
||||
|
||||
await expect(
|
||||
storageApi.getBaseUrl('../test.js', mockEntity, 'some-docs-path'),
|
||||
).resolves.toEqual(
|
||||
`${mockBaseUrl}/static/docs/${mockEntity.namespace}/${mockEntity.kind}/${mockEntity.name}/test.js`,
|
||||
);
|
||||
});
|
||||
|
||||
it('should return base url with correct entity structure', async () => {
|
||||
|
||||
@@ -263,9 +263,11 @@ export class TechDocsStorageClient implements TechDocsStorageApi {
|
||||
const { kind, namespace, name } = entityId;
|
||||
|
||||
const apiOrigin = await this.getApiOrigin();
|
||||
const newBaseUrl = `${apiOrigin}/static/docs/${namespace}/${kind}/${name}/${path}`;
|
||||
|
||||
return new URL(
|
||||
oldBaseUrl,
|
||||
`${apiOrigin}/static/docs/${namespace}/${kind}/${name}/${path}`,
|
||||
newBaseUrl.endsWith('/') ? newBaseUrl : `${newBaseUrl}/`,
|
||||
).toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user