From f2a9bba5e27ad2e2ec29d3fdccec303d8de1e808 Mon Sep 17 00:00:00 2001 From: Marvin9 Date: Tue, 27 Oct 2020 10:53:40 +0530 Subject: [PATCH] feat: update related to #3066 --- .../src/lib/catalog/CatalogEntityClient.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/scaffolder-backend/src/lib/catalog/CatalogEntityClient.ts b/plugins/scaffolder-backend/src/lib/catalog/CatalogEntityClient.ts index 84676b63fe..4541f03a4a 100644 --- a/plugins/scaffolder-backend/src/lib/catalog/CatalogEntityClient.ts +++ b/plugins/scaffolder-backend/src/lib/catalog/CatalogEntityClient.ts @@ -38,13 +38,15 @@ export class CatalogEntityClient { * Throws a NotFoundError or ConflictError if 0 or multiple templates are found. */ async findTemplate(templateName: string): Promise { - const params = new URLSearchParams(); - params.append('kind', 'Template'); - - params.append('metadata.name', templateName); + const conditions = [ + 'kind=template', + `metadata.name=${encodeURIComponent(templateName)}`, + ]; const baseUrl = await this.discovery.getBaseUrl('catalog'); - const response = await fetch(`${baseUrl}/entities?${params}`); + const response = await fetch( + `${baseUrl}/entities?filter=${conditions.join(',')}`, + ); if (!response.ok) { const text = await response.text();