@@ -17,7 +17,6 @@ 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' ;
2120
2221function isTelemetryEnabled ( ) : boolean {
2322 const TELEMETRY_CONFIG_ID = 'telemetry' ;
@@ -301,31 +300,14 @@ export interface WorkspaceData {
301300 phase : WorkspacePhase ;
302301 description : string ;
303302 lastUsed : Date ;
304- recentFolders : string [ ] ;
303+ recentFolders : string [ ] ;
305304}
306305
307- export function rawWorkspaceToWorkspaceData ( rawWorkspaces : Workspace ) : WorkspaceData | undefined ;
306+ export function rawWorkspaceToWorkspaceData ( rawWorkspaces : Workspace ) : WorkspaceData ;
308307export function rawWorkspaceToWorkspaceData ( rawWorkspaces : Workspace [ ] ) : WorkspaceData [ ] ;
309308export function rawWorkspaceToWorkspaceData ( rawWorkspaces : Workspace | Workspace [ ] ) {
310309 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 ) ;
329311 const provider = url . host . replace ( / \. .+ ?$ / , '' ) ; // remove '.com', etc
330312 const matches = url . pathname . match ( / [ ^ / ] + / g) ! ; // match /owner/repo
331313 const owner = matches [ 0 ] ;
@@ -335,7 +317,7 @@ export function rawWorkspaceToWorkspaceData(rawWorkspaces: Workspace | Workspace
335317 owner,
336318 repo,
337319 id : ws . workspaceId ,
338- contextUrl : url . toString ( ) ,
320+ contextUrl : ws . context ! . contextUrl ,
339321 workspaceUrl : ws . status ! . instance ! . status ! . url ,
340322 phase : WorkspaceInstanceStatus_Phase [ ws . status ! . instance ! . status ! . phase ?? WorkspaceInstanceStatus_Phase . UNSPECIFIED ] . toLowerCase ( ) as WorkspacePhase ,
341323 description : ws . description ,
@@ -346,7 +328,7 @@ export function rawWorkspaceToWorkspaceData(rawWorkspaces: Workspace | Workspace
346328
347329 if ( Array . isArray ( rawWorkspaces ) ) {
348330 rawWorkspaces = rawWorkspaces . filter ( ws => ws . context ?. details . case === 'git' ) ;
349- return rawWorkspaces . map ( toWorkspaceData ) . filter ( e => ! ! e ) ;
331+ return rawWorkspaces . map ( toWorkspaceData ) ;
350332 }
351333
352334 return toWorkspaceData ( rawWorkspaces ) ;
0 commit comments