Skip to content

Commit 9338a24

Browse files
authored
fix: preview URL @W-20474734 (#576)
* fix: simplify component preview URL generation in PreviewUtils * fix: streamline component preview URL generation in LightningDevComponent
1 parent db7354b commit 9338a24

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/commands/lightning/dev/component.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,7 @@ export default class LightningDevComponent extends SfCommand<ComponentPreviewRes
167167
// strip trailing slashes
168168
const instanceUrl = connection.instanceUrl.replace(/\/$/, '');
169169

170-
const previewUrl = PreviewUtils.generateComponentPreviewUrl(
171-
instanceUrl,
172-
ldpServerUrl,
173-
ldpServerId,
174-
componentName,
175-
false
176-
);
170+
const previewUrl = PreviewUtils.generateComponentPreviewUrl(instanceUrl, ldpServerUrl, ldpServerId, componentName);
177171

178172
// Prepare the result for JSON output
179173
const result: ComponentPreviewResult = {

src/shared/previewUtils.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,7 @@ export class PreviewUtils {
229229
componentName?: string,
230230
targetOrg?: string
231231
): string[] {
232-
let appPath = `lwr/application/e/devpreview/ai/${encodeURIComponent(
233-
'localdev%2Fpreview'
234-
)}?ldpServerUrl=${ldpServerUrl}&ldpServerId=${ldpServerId}`;
232+
let appPath = `lwr/application/e/devpreview/ai/localdev-preview?ldpServerUrl=${ldpServerUrl}&ldpServerId=${ldpServerId}`;
235233
if (componentName) {
236234
// TODO: support other namespaces
237235
appPath += `&specifier=c/${componentName}`;
@@ -253,19 +251,15 @@ export class PreviewUtils {
253251
* @param ldpServerUrl The URL for the local dev server
254252
* @param ldpServerId Record ID for the identity token
255253
* @param componentName The name of the component to preview
256-
* @param encodePath Whether to encode the path
257254
* @returns The full URL for the component preview
258255
*/
259256
public static generateComponentPreviewUrl(
260257
instanceUrl: string,
261258
ldpServerUrl: string,
262259
ldpServerId: string,
263-
componentName?: string,
264-
encodePath = false
260+
componentName?: string
265261
): string {
266-
let url = `${instanceUrl}/lwr/application/e/devpreview/ai/${
267-
encodePath ? encodeURIComponent('localdev%2Fpreview') : 'localdev%2Fpreview'
268-
}?ldpServerUrl=${ldpServerUrl}&ldpServerId=${ldpServerId}`;
262+
let url = `${instanceUrl}/lwr/application/e/devpreview/ai/localdev-preview?ldpServerUrl=${ldpServerUrl}&ldpServerId=${ldpServerId}`;
269263
if (componentName) {
270264
// TODO: support other namespaces
271265
url += `&specifier=c/${componentName}`;

0 commit comments

Comments
 (0)