@@ -17,6 +17,7 @@ import { MetricsReporter, getConnectMetricsInterceptor } from './metrics';
1717import { ILogService } from './services/logService' ;
1818import { WrapError } from './common/utils' ;
1919import { ITelemetryService } from './common/telemetry' ;
20+ import { ContextURL } from '@gitpod/gitpod-protocol' ;
2021
2122function isTelemetryEnabled ( ) : boolean {
2223 const TELEMETRY_CONFIG_ID = 'telemetry' ;
@@ -307,10 +308,7 @@ export function rawWorkspaceToWorkspaceData(rawWorkspaces: Workspace): Workspace
307308export function rawWorkspaceToWorkspaceData ( rawWorkspaces : Workspace [ ] ) : WorkspaceData [ ] ;
308309export function rawWorkspaceToWorkspaceData ( rawWorkspaces : Workspace | Workspace [ ] ) {
309310 const toWorkspaceData = ( ws : Workspace ) => {
310- // https://github.com/gitpod-io/gitpod/blob/7e0c605a3d470b8cee0e841e51da9b20022f4f4b/components/public-api-server/pkg/apiv1/workspace.go#L332-L335
311- // it's always git context, safe to go
312- const contextUrl = ws . context ?. details . case === 'git' ? ws . context . details . value . normalizedContextUrl : ws . context ! . contextUrl ;
313- const url = new URL ( contextUrl ) ;
311+ const url = ContextURL . getNormalizedURL ( { contextURL : ws . context ! . contextUrl } as any ) ! ;
314312 const provider = url . host . replace ( / \. .+ ?$ / , '' ) ; // remove '.com', etc
315313 const matches = url . pathname . match ( / [ ^ / ] + / g) ! ; // match /owner/repo
316314 const owner = matches [ 0 ] ;
@@ -320,7 +318,7 @@ export function rawWorkspaceToWorkspaceData(rawWorkspaces: Workspace | Workspace
320318 owner,
321319 repo,
322320 id : ws . workspaceId ,
323- contextUrl,
321+ contextUrl : url . toString ( ) ,
324322 workspaceUrl : ws . status ! . instance ! . status ! . url ,
325323 phase : WorkspaceInstanceStatus_Phase [ ws . status ! . instance ! . status ! . phase ?? WorkspaceInstanceStatus_Phase . UNSPECIFIED ] . toLowerCase ( ) as WorkspacePhase ,
326324 description : ws . description ,
@@ -331,7 +329,7 @@ export function rawWorkspaceToWorkspaceData(rawWorkspaces: Workspace | Workspace
331329
332330 if ( Array . isArray ( rawWorkspaces ) ) {
333331 rawWorkspaces = rawWorkspaces . filter ( ws => ws . context ?. details . case === 'git' ) ;
334- return rawWorkspaces . map ( toWorkspaceData ) ;
332+ return rawWorkspaces . map ( toWorkspaceData ) . filter ( e => ! ! e ) ;
335333 }
336334
337335 return toWorkspaceData ( rawWorkspaces ) ;
0 commit comments