File tree Expand file tree Collapse file tree 2 files changed +35
-4
lines changed
Expand file tree Collapse file tree 2 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -131,10 +131,23 @@ export default class LightningDevComponent extends SfCommand<void> {
131131
132132 // Construct and log the full URL that will be opened
133133 const connection = targetOrg . getConnection ( ) ;
134- // Decode the path once to match what org:open actually opens
135- const decodedPath = decodeURIComponent ( launchArguments [ 1 ] ) ;
136- const fullUrl = `${ connection . instanceUrl } /${ decodedPath } ` ;
137- this . log ( `PreviewURL: ${ fullUrl } ` ) ;
134+
135+ const decodedFullUrl = PreviewUtils . generateComponentPreviewUrl (
136+ connection . instanceUrl ,
137+ ldpServerUrl ,
138+ ldpServerId ,
139+ componentName ,
140+ false
141+ ) ;
142+ // const encodedFullUrl = PreviewUtils.generateComponentPreviewUrl(
143+ // connection.instanceUrl,
144+ // ldpServerUrl,
145+ // ldpServerId,
146+ // componentName,
147+ // true
148+ // );
149+ this . log ( `PreviewURL: ${ decodedFullUrl } ` ) ;
150+ // this.log(`EncodedPreviewURL: ${encodedFullUrl}`);
138151
139152 // Open the browser and navigate to the right page (unless OPEN_BROWSER is set to true)
140153 if ( process . env . OPEN_BROWSER !== 'false' ) {
Original file line number Diff line number Diff line change @@ -246,6 +246,24 @@ export class PreviewUtils {
246246 return launchArguments ;
247247 }
248248
249+ public static generateComponentPreviewUrl (
250+ instanceUrl : string ,
251+ ldpServerUrl : string ,
252+ ldpServerId : string ,
253+ componentName ?: string ,
254+ encodePath = false
255+ ) : string {
256+ let url = `${ instanceUrl } /lwr/application/e/devpreview/ai/${
257+ encodePath ? encodeURIComponent ( 'localdev%2Fpreview' ) : 'localdev%2Fpreview'
258+ } ?ldpServerUrl=${ ldpServerUrl } &ldpServerId=${ ldpServerId } `;
259+ if ( componentName ) {
260+ // TODO: support other namespaces
261+ url += `&specifier=c/${ componentName } ` ;
262+ }
263+
264+ return url ;
265+ }
266+
249267 /**
250268 * Generates the proper set of arguments to be used for launching a mobile app with custom launch arguments.
251269 *
You can’t perform that action at this time.
0 commit comments