Skip to content

Commit 57376f4

Browse files
fix: correct retURL to startURL for OTP URLs W-18077630 (#1387)
* fix: correct retURL to startURL for OTP URLs * chore: only encode agent urls for OTP
1 parent d95f3b8 commit 57376f4

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/commands/org/open/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class OrgOpenAgent extends OrgOpenCommandBase<OrgOpenOutput> {
5757
buildRetUrl(this.connection, flags.name),
5858
]);
5959

60-
return this.openOrgUI(flags, frontDoorUrl, retUrl);
60+
return this.openOrgUI(flags, frontDoorUrl, encodeURIComponent(retUrl));
6161
}
6262
}
6363

src/shared/orgOpenCommandBase.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ export abstract class OrgOpenCommandBase<T> extends SfCommand<T> {
3636

3737
protected async openOrgUI(flags: OrgOpenFlags, frontDoorUrl: string, retUrl?: string): Promise<OrgOpenOutput> {
3838
const orgId = this.org.getOrgId();
39-
const url = `${frontDoorUrl}${retUrl ? `&retURL=${retUrl}` : ''}`;
39+
const url = `${frontDoorUrl}${
40+
retUrl ? `&${frontDoorUrl.includes('.jsp?otp=') ? `startURL=${retUrl}` : `retURL=${retUrl}`}` : ''
41+
}`;
4042

4143
// TODO: better typings in sfdx-core for orgs read from auth files
4244
const username = this.org.getUsername() as string;

test/unit/org/open.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import { EventEmitter } from 'node:events';
88
import fs from 'node:fs';
99
import { join } from 'node:path';
10+
import * as process from 'node:process';
1011
import { assert, expect } from 'chai';
11-
import { SfdcUrl, Messages, Connection, SfError } from '@salesforce/core';
12+
import { Connection, Messages, SfdcUrl, SfError } from '@salesforce/core';
1213
import { stubMethod } from '@salesforce/ts-sinon';
1314
import { MockTestOrgData, shouldThrow, TestContext } from '@salesforce/core/testSetup';
1415
import { stubSfCommandUx, stubSpinner, stubUx } from '@salesforce/sf-plugins-core';

0 commit comments

Comments
 (0)