From 59d401ba693d468655ef055e0488d11f0426d85e Mon Sep 17 00:00:00 2001 From: Alex Tideman Date: Fri, 5 Jul 2024 09:37:27 -0500 Subject: [PATCH 1/4] Remove double encoding --- src/lib/utilities/route-for-api.test.ts | 4 ++-- src/lib/utilities/route-for-api.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/utilities/route-for-api.test.ts b/src/lib/utilities/route-for-api.test.ts index ac4b14a87..dcad75caf 100644 --- a/src/lib/utilities/route-for-api.test.ts +++ b/src/lib/utilities/route-for-api.test.ts @@ -181,7 +181,7 @@ describe('API Request Encoding', () => { workflowId: 'workflow#with#hashes', }); expect(route).toBe( - 'http://localhost:8233/api/v1/namespaces/namespace/workflows/workflow%2523with%2523hashes', + 'http://localhost:8233/api/v1/namespaces/namespace/workflows/workflow%23with%23hashes', ); }); @@ -194,7 +194,7 @@ describe('API Request Encoding', () => { 'temporal.canary.cron-workflow.sanity-2022-05-02T16:03:11-06:00/workflow.advanced-visibility.scan', }); expect(route).toBe( - 'http://localhost:8233/api/v1/namespaces/canary/workflows/temporal.canary.cron-workflow.sanity-2022-05-02T16%253A03%253A11-06%253A00%252Fworkflow.advanced-visibility.scan', + 'http://localhost:8233/api/v1/namespaces/canary/workflows/temporal.canary.cron-workflow.sanity-2022-05-02T16%3A03%3A11-06%3A00%2Fworkflow.advanced-visibility.scan', ); }); }); diff --git a/src/lib/utilities/route-for-api.ts b/src/lib/utilities/route-for-api.ts index 7ebb7d19d..c51143501 100644 --- a/src/lib/utilities/route-for-api.ts +++ b/src/lib/utilities/route-for-api.ts @@ -81,7 +81,7 @@ const encode = ( ): APIRouteParameters => { return Object.keys(parameters ?? {}).reduce( (acc, key) => { - acc[key] = encodeURIComponent(encodeURIComponent(parameters[key])); + acc[key] = encodeURIComponent(parameters[key]); return acc; }, { From b2a6ef4aef3243f1c8e7b556a310719dbaebd499 Mon Sep 17 00:00:00 2001 From: Alex Tideman Date: Mon, 8 Jul 2024 10:54:48 -0500 Subject: [PATCH 2/4] Add version check for double encoding --- package.json | 2 +- src/lib/utilities/route-for-api.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 229b62d3a..18a1088db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@temporalio/ui", - "version": "2.27.15", + "version": "2.28.0-decode.1", "engines": { "pnpm": ">=8.6.0", "node": ">=18.15.0" diff --git a/src/lib/utilities/route-for-api.ts b/src/lib/utilities/route-for-api.ts index c51143501..92c1bb529 100644 --- a/src/lib/utilities/route-for-api.ts +++ b/src/lib/utilities/route-for-api.ts @@ -33,6 +33,7 @@ import type { } from '$lib/types/api'; import { getApiOrigin } from './get-api-origin'; +import { minimumVersionRequired } from './version-check'; const replaceNamespaceInApiUrl = ( apiUrl: string, @@ -79,9 +80,15 @@ const withBase = (path: string, namespace?: string): string => { const encode = ( parameters: Partial, ): APIRouteParameters => { + const version = get(page)?.data?.settings?.version; return Object.keys(parameters ?? {}).reduce( (acc, key) => { - acc[key] = encodeURIComponent(parameters[key]); + if (version && minimumVersionRequired('2.23.0', version)) { + console.log('SINGLE ENCODING'); + acc[key] = encodeURIComponent(parameters[key]); + } else { + acc[key] = encodeURIComponent(encodeURIComponent(parameters[key])); + } return acc; }, { From dccbea48c08054020ef15c898c02430da47bc2c7 Mon Sep 17 00:00:00 2001 From: Alex Tideman Date: Mon, 8 Jul 2024 11:13:44 -0500 Subject: [PATCH 3/4] Remove console log and version tag --- package.json | 2 +- src/lib/utilities/route-for-api.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 18a1088db..229b62d3a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@temporalio/ui", - "version": "2.28.0-decode.1", + "version": "2.27.15", "engines": { "pnpm": ">=8.6.0", "node": ">=18.15.0" diff --git a/src/lib/utilities/route-for-api.ts b/src/lib/utilities/route-for-api.ts index 92c1bb529..5ed1b9e0a 100644 --- a/src/lib/utilities/route-for-api.ts +++ b/src/lib/utilities/route-for-api.ts @@ -84,7 +84,6 @@ const encode = ( return Object.keys(parameters ?? {}).reduce( (acc, key) => { if (version && minimumVersionRequired('2.23.0', version)) { - console.log('SINGLE ENCODING'); acc[key] = encodeURIComponent(parameters[key]); } else { acc[key] = encodeURIComponent(encodeURIComponent(parameters[key])); From 1d8ff66b5aad86b0f98f0ed1f7e458dc22320cd7 Mon Sep 17 00:00:00 2001 From: Alex Tideman Date: Mon, 8 Jul 2024 11:15:35 -0500 Subject: [PATCH 4/4] Update data store version --- src/lib/svelte-mocks/app/stores.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/svelte-mocks/app/stores.ts b/src/lib/svelte-mocks/app/stores.ts index d81413173..6cf441309 100644 --- a/src/lib/svelte-mocks/app/stores.ts +++ b/src/lib/svelte-mocks/app/stores.ts @@ -39,7 +39,7 @@ const settings: Settings = { isLocal: true, envOverride: true, }, - version: '2.0.0', + version: '2.28.0', }; const data: App.PageData = {