diff --git a/src/csm/createEditUrl.ts b/src/csm/createEditUrl.ts index 01496a3f..5d33ad30 100644 --- a/src/csm/createEditUrl.ts +++ b/src/csm/createEditUrl.ts @@ -55,10 +55,10 @@ export function createEditUrl(options: CreateEditUrlOptions): `${StudioBaseUrl}$ if (workspace) { segments.push(workspace) } + const routerParams = [`id=${id}`, `type=${type}`, `path=${encodeURIComponent(stringifiedPath)}`] if (tool) { - segments.push(tool) + routerParams.push(`tool=${tool}`) } - const routerParams = [`id=${id}`, `type=${type}`, `path=${encodeURIComponent(stringifiedPath)}`] segments.push('intent', 'edit', `${routerParams.join(';')}?${searchParams}`) return segments.join('/') as unknown as `${StudioBaseUrl}${EditIntentUrl}` } diff --git a/test/csm/createEditUrl.test.ts b/test/csm/createEditUrl.test.ts index 36bbe20f..e329f0fa 100644 --- a/test/csm/createEditUrl.test.ts +++ b/test/csm/createEditUrl.test.ts @@ -14,7 +14,7 @@ const cases = [ context: {baseUrl, workspace, tool, id, type}, path: parseJsonPath("$['foo'][?(@._key=='section-1')][0]['baz'][?(@._key=='section-2')]"), expected: - 'https://test.sanity.studio/staging/content/intent/edit/id=homepage;type=page;path=foo[_key=="section-1"][0].baz[_key=="section-2"]?baseUrl=https://test.sanity.studio&id=homepage&type=page&path=foo[_key=="section-1"][0].baz[_key=="section-2"]&workspace=staging&tool=content', + 'https://test.sanity.studio/staging/intent/edit/id=homepage;type=page;path=foo[_key=="section-1"][0].baz[_key=="section-2"];tool=content?baseUrl=https://test.sanity.studio&id=homepage&type=page&path=foo[_key=="section-1"][0].baz[_key=="section-2"]&workspace=staging&tool=content', }, { context: {baseUrl: '/', id, type}, @@ -26,7 +26,7 @@ const cases = [ context: {baseUrl: '/', workspace, tool, id, type}, path: parseJsonPath("$['foo'][?(@._key=='section-1')][0]"), expected: - '/staging/content/intent/edit/id=homepage;type=page;path=foo[_key=="section-1"][0]?baseUrl=/&id=homepage&type=page&path=foo[_key=="section-1"][0]&workspace=staging&tool=content', + '/staging/intent/edit/id=homepage;type=page;path=foo[_key=="section-1"][0];tool=content?baseUrl=/&id=homepage&type=page&path=foo[_key=="section-1"][0]&workspace=staging&tool=content', }, ]