@@ -138,7 +138,6 @@ import { FileDecorationProvider } from "./providers/FileDecorationProvider";
138138import { RESTDebugPanel } from "./commands/restDebugPanel" ;
139139import { modifyWsFolder } from "./commands/addServerNamespaceToWorkspace" ;
140140import { WebSocketTerminalProfileProvider , launchWebSocketTerminal } from "./commands/webSocketTerminal" ;
141- import { getCSPToken } from "./utils/getCSPToken" ;
142141import { setUpTestController } from "./commands/unitTest" ;
143142
144143const packageJson = vscode . extensions . getExtension ( extensionId ) . packageJSON ;
@@ -1384,20 +1383,24 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
13841383 vscode . commands . registerCommand (
13851384 "vscode-objectscript.openPathInBrowser" ,
13861385 async ( path : string , docUri : vscode . Uri ) => {
1387- if ( typeof path == "string" && docUri && docUri instanceof vscode . Uri ) {
1386+ if ( typeof path == "string" && docUri instanceof vscode . Uri ) {
13881387 const api = new AtelierAPI ( docUri ) ;
1389- let uri = vscode . Uri . parse (
1390- `${ api . config . https ? "https" : "http" } ://${ api . config . host } :${ api . config . port } ${
1391- api . config . pathPrefix
1392- } ${ path } `
1388+ // Get the default web application for this namespace.
1389+ // If it can't be determined, fall back to the /csp/<namespace> web application.
1390+ const app : string =
1391+ ( await api
1392+ . getCSPApps ( true )
1393+ . then ( ( data ) => data . result . content . find ( ( a ) => a . default ) ?. name )
1394+ . catch ( ( ) => {
1395+ // Swallow errors
1396+ } ) ) ?? `/csp/${ api . ns } ` ;
1397+ vscode . env . openExternal (
1398+ vscode . Uri . parse (
1399+ `${ api . config . https ? "https" : "http" } ://${ api . config . host } :${ api . config . port } ${
1400+ api . config . pathPrefix
1401+ } ${ app } ${ path } `
1402+ )
13931403 ) ;
1394- const token = await getCSPToken ( api , path . split ( "?" ) [ 0 ] ) . catch ( ( ) => "" ) ;
1395- if ( token . length > 0 ) {
1396- uri = uri . with ( {
1397- query : uri . query . length ? `${ uri . query } &CSPCHD=${ token } ` : `CSPCHD=${ token } ` ,
1398- } ) ;
1399- }
1400- vscode . env . openExternal ( uri ) ;
14011404 }
14021405 }
14031406 ) ,
0 commit comments