@@ -417,6 +417,13 @@ export class Gitpod {
417417 } ) ;
418418 }
419419
420+ /**
421+ * Check whether the base URL is set to its default.
422+ */
423+ #baseURLOverridden( ) : boolean {
424+ return this . baseURL !== 'https://app.gitpod.io/api' ;
425+ }
426+
420427 protected defaultQuery ( ) : Record < string , string | undefined > | undefined {
421428 return this . _options . defaultQuery ;
422429 }
@@ -466,11 +473,16 @@ export class Gitpod {
466473 return Errors . APIError . generate ( status , error , message , headers ) ;
467474 }
468475
469- buildURL ( path : string , query : Record < string , unknown > | null | undefined ) : string {
476+ buildURL (
477+ path : string ,
478+ query : Record < string , unknown > | null | undefined ,
479+ defaultBaseURL ?: string | undefined ,
480+ ) : string {
481+ const baseURL = ( ! this . #baseURLOverridden( ) && defaultBaseURL ) || this . baseURL ;
470482 const url =
471483 isAbsoluteURL ( path ) ?
472484 new URL ( path )
473- : new URL ( this . baseURL + ( this . baseURL . endsWith ( '/' ) && path . startsWith ( '/' ) ? path . slice ( 1 ) : path ) ) ;
485+ : new URL ( baseURL + ( baseURL . endsWith ( '/' ) && path . startsWith ( '/' ) ? path . slice ( 1 ) : path ) ) ;
474486
475487 const defaultQuery = this . defaultQuery ( ) ;
476488 if ( ! isEmptyObj ( defaultQuery ) ) {
@@ -830,9 +842,9 @@ export class Gitpod {
830842 { retryCount = 0 } : { retryCount ?: number } = { } ,
831843 ) : { req : FinalizedRequestInit ; url : string ; timeout : number } {
832844 const options = { ...inputOptions } ;
833- const { method, path, query } = options ;
845+ const { method, path, query, defaultBaseURL } = options ;
834846
835- const url = this . buildURL ( path ! , query as Record < string , unknown > ) ;
847+ const url = this . buildURL ( path ! , query as Record < string , unknown > , defaultBaseURL ) ;
836848 if ( 'timeout' in options ) validatePositiveInteger ( 'timeout' , options . timeout ) ;
837849 options . timeout = options . timeout ?? this . timeout ;
838850 const { bodyHeaders, body } = this . buildBody ( { options } ) ;
0 commit comments