@@ -17,7 +17,6 @@ import { MetricsReporter, getConnectMetricsInterceptor } from './metrics';
17
17
import { ILogService } from './services/logService' ;
18
18
import { WrapError } from './common/utils' ;
19
19
import { ITelemetryService } from './common/telemetry' ;
20
- import { ContextURL } from '@gitpod/gitpod-protocol' ;
21
20
22
21
function isTelemetryEnabled ( ) : boolean {
23
22
const TELEMETRY_CONFIG_ID = 'telemetry' ;
@@ -301,31 +300,14 @@ export interface WorkspaceData {
301
300
phase : WorkspacePhase ;
302
301
description : string ;
303
302
lastUsed : Date ;
304
- recentFolders : string [ ] ;
303
+ recentFolders : string [ ] ;
305
304
}
306
305
307
- export function rawWorkspaceToWorkspaceData ( rawWorkspaces : Workspace ) : WorkspaceData | undefined ;
306
+ export function rawWorkspaceToWorkspaceData ( rawWorkspaces : Workspace ) : WorkspaceData ;
308
307
export function rawWorkspaceToWorkspaceData ( rawWorkspaces : Workspace [ ] ) : WorkspaceData [ ] ;
309
308
export function rawWorkspaceToWorkspaceData ( rawWorkspaces : Workspace | Workspace [ ] ) {
310
309
const toWorkspaceData = ( ws : Workspace ) => {
311
- let url : URL ;
312
- try {
313
- if (
314
- ws . context ?. details . case === 'git' &&
315
- ws . context . details . value . normalizedContextUrl !== ws . context . contextUrl // backward compatible
316
- ) {
317
- url = new URL ( ws . context . details . value . normalizedContextUrl ) ;
318
- } else {
319
- const normalized = ContextURL . getNormalizedURL ( { context : { } , contextURL : ws . context ! . contextUrl } as any ) ;
320
- if ( ! normalized ) {
321
- return undefined ;
322
- }
323
- url = normalized ;
324
- }
325
- } catch ( e ) {
326
- // TODO: send exception
327
- return undefined ;
328
- }
310
+ const url = new URL ( ws . context ! . contextUrl ) ;
329
311
const provider = url . host . replace ( / \. .+ ?$ / , '' ) ; // remove '.com', etc
330
312
const matches = url . pathname . match ( / [ ^ / ] + / g) ! ; // match /owner/repo
331
313
const owner = matches [ 0 ] ;
@@ -335,7 +317,7 @@ export function rawWorkspaceToWorkspaceData(rawWorkspaces: Workspace | Workspace
335
317
owner,
336
318
repo,
337
319
id : ws . workspaceId ,
338
- contextUrl : url . toString ( ) ,
320
+ contextUrl : ws . context ! . contextUrl ,
339
321
workspaceUrl : ws . status ! . instance ! . status ! . url ,
340
322
phase : WorkspaceInstanceStatus_Phase [ ws . status ! . instance ! . status ! . phase ?? WorkspaceInstanceStatus_Phase . UNSPECIFIED ] . toLowerCase ( ) as WorkspacePhase ,
341
323
description : ws . description ,
@@ -346,7 +328,7 @@ export function rawWorkspaceToWorkspaceData(rawWorkspaces: Workspace | Workspace
346
328
347
329
if ( Array . isArray ( rawWorkspaces ) ) {
348
330
rawWorkspaces = rawWorkspaces . filter ( ws => ws . context ?. details . case === 'git' ) ;
349
- return rawWorkspaces . map ( toWorkspaceData ) . filter ( e => ! ! e ) ;
331
+ return rawWorkspaces . map ( toWorkspaceData ) ;
350
332
}
351
333
352
334
return toWorkspaceData ( rawWorkspaces ) ;
0 commit comments