Skip to content

Commit

Permalink
fix(csm): don't apply tool to baseUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Nov 13, 2023
1 parent b01840d commit a836c7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/csm/createEditUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
}
4 changes: 2 additions & 2 deletions test/csm/createEditUrl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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',
},
]

Expand Down

0 comments on commit a836c7c

Please sign in to comment.