fix(catalog): unbreak the catalog client (#3106)
This commit is contained in:
@@ -34,7 +34,7 @@ describe('CatalogClient', () => {
|
||||
client = new CatalogClient({ discoveryApi });
|
||||
});
|
||||
|
||||
describe('getEntiies', () => {
|
||||
describe('getEntities', () => {
|
||||
const defaultResponse: Entity[] = [
|
||||
{
|
||||
apiVersion: '1',
|
||||
@@ -71,9 +71,7 @@ describe('CatalogClient', () => {
|
||||
expect.assertions(2);
|
||||
server.use(
|
||||
rest.get(`${mockBaseUrl}/entities`, (req, res, ctx) => {
|
||||
expect(req.url.searchParams.toString()).toBe(
|
||||
'a=1&b=2&b=3&%C3%B6=%3D',
|
||||
);
|
||||
expect(req.url.search).toBe('?filter=a=1,b=2,b=3,%C3%B6=%3D');
|
||||
return res(ctx.json([]));
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -68,17 +68,13 @@ export class CatalogClient implements CatalogApi {
|
||||
): Promise<Entity[]> {
|
||||
let path = `/entities`;
|
||||
if (filter) {
|
||||
const params = new URLSearchParams();
|
||||
const parts: string[] = [];
|
||||
for (const [key, value] of Object.entries(filter)) {
|
||||
if (Array.isArray(value)) {
|
||||
for (const v of value) {
|
||||
params.append(key, v);
|
||||
}
|
||||
} else {
|
||||
params.append(key, value);
|
||||
for (const v of [value].flat()) {
|
||||
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(v)}`);
|
||||
}
|
||||
}
|
||||
path += `?${params.toString()}`;
|
||||
path += `?filter=${parts.join(',')}`;
|
||||
}
|
||||
|
||||
return await this.getRequired(path);
|
||||
|
||||
Reference in New Issue
Block a user