Make sure the CatalogClient escapes URL parameters correctly

Signed-off-by: Oliver Sand <oliver.sand@sda-se.com>
This commit is contained in:
Oliver Sand
2021-04-14 14:06:09 +02:00
parent 7fd46f26dc
commit 442f34b87f
4 changed files with 26 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/catalog-client': patch
---
Make sure the `CatalogClient` escapes URL parameters correctly.
+19 -5
View File
@@ -42,10 +42,14 @@ export class CatalogClient implements CatalogApi {
}
async getLocationById(
id: String,
id: string,
options?: CatalogRequestOptions,
): Promise<Location | undefined> {
return await this.requestOptional('GET', `/locations/${id}`, options);
return await this.requestOptional(
'GET',
`/locations/${encodeURIComponent(id)}`,
options,
);
}
async getEntities(
@@ -86,7 +90,9 @@ export class CatalogClient implements CatalogApi {
const { kind, namespace = 'default', name } = compoundName;
return this.requestOptional(
'GET',
`/entities/by-name/${kind}/${namespace}/${name}`,
`/entities/by-name/${encodeURIComponent(kind)}/${encodeURIComponent(
namespace,
)}/${encodeURIComponent(name)}`,
options,
);
}
@@ -171,14 +177,22 @@ export class CatalogClient implements CatalogApi {
id: string,
options?: CatalogRequestOptions,
): Promise<void> {
await this.requestIgnored('DELETE', `/locations/${id}`, options);
await this.requestIgnored(
'DELETE',
`/locations/${encodeURIComponent(id)}`,
options,
);
}
async removeEntityByUid(
uid: string,
options?: CatalogRequestOptions,
): Promise<void> {
await this.requestIgnored('DELETE', `/entities/by-uid/${uid}`, options);
await this.requestIgnored(
'DELETE',
`/entities/by-uid/${encodeURIComponent(uid)}`,
options,
);
}
//
+1 -1
View File
@@ -46,7 +46,7 @@ export interface CatalogApi {
// Locations
getLocationById(
id: String,
id: string,
options?: CatalogRequestOptions,
): Promise<Location | undefined>;
getOriginLocationByEntity(
+1 -1
View File
@@ -42,7 +42,7 @@ export class CatalogClientWrapper implements CatalogApi {
}
async getLocationById(
id: String,
id: string,
options?: CatalogRequestOptions,
): Promise<Location | undefined> {
return await this.client.getLocationById(id, {