From ad3fb540172964c20c086ab8d317c496d28cdba1 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 10 Aug 2023 16:40:26 +0200 Subject: [PATCH] todo: fix filter encoding Signed-off-by: Patrik Oldsberg --- .changeset/pretty-ways-knock.md | 5 +++++ plugins/todo/src/api/TodoClient.ts | 18 +++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 .changeset/pretty-ways-knock.md diff --git a/.changeset/pretty-ways-knock.md b/.changeset/pretty-ways-knock.md new file mode 100644 index 0000000000..d06a107fe3 --- /dev/null +++ b/.changeset/pretty-ways-knock.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-todo': patch +--- + +Fixed URL encoding of filters where the filter was always rejected by the backend validation. diff --git a/plugins/todo/src/api/TodoClient.ts b/plugins/todo/src/api/TodoClient.ts index 4bfd5b77e5..e86e444c30 100644 --- a/plugins/todo/src/api/TodoClient.ts +++ b/plugins/todo/src/api/TodoClient.ts @@ -67,13 +67,17 @@ export class TodoClient implements TodoApi { } } - const res = await fetch(`${baseUrl}/v1/todos?${query}`, { - headers: token - ? { - Authorization: `Bearer ${token}`, - } - : undefined, - }); + const res = await fetch( + // TODO(Rugvip): Figure out a better solution to '*' not being URL encoded but that being required by OpenAPI + `${baseUrl}/v1/todos?${String(query).replace(/\*/g, '%2A')}`, + { + headers: token + ? { + Authorization: `Bearer ${token}`, + } + : undefined, + }, + ); if (!res.ok) { throw await ResponseError.fromResponse(res);