@@ -260,18 +260,34 @@ function oAuthFlowTemplate(flowName, clientId, clientSecret, securitySchemeId, a
260260 let { authorizationUrl, tokenUrl, refreshUrl } = authFlow ;
261261 const pkceOnly = authFlow [ 'x-pkce-only' ] || false ;
262262 const isUrlAbsolute = ( url ) => ( url . indexOf ( '://' ) > 0 || url . indexOf ( '//' ) === 0 ) ;
263- // Calculcate base URL
263+ /*
264+ Calculcate Relative URL based on the following logic
265+ IF this.selectedServer?.computedUrl ends with slash and the refreshUrl / tokenUrl / authorizationUrl do not start with slash
266+ THEN Relative URL is concatenate else use this.selectedServer?.computedUrl + refreshUrl / tokenUrl / authorizationUrl
267+ ELSE Relative URL is concatenate else use (origin of this.selectedServer?.computedUrl) + refreshUrl / tokenUrl / authorizationUrl
268+ */
264269 const url = new URL ( this . selectedServer ?. computedUrl ) ;
265- const baseUrl = url . origin ;
266-
270+ const originUrl = url . origin ;
267271 if ( refreshUrl && ! isUrlAbsolute ( refreshUrl ) ) {
268- refreshUrl = `${ baseUrl } /${ refreshUrl . replace ( / ^ \/ / , '' ) } ` ;
272+ if ( this . selectedServer ?. computedUrl . trim ( ) . endsWith ( '/' ) && ! refreshUrl . trim ( ) . startsWith ( '/' ) ) {
273+ refreshUrl = `${ this . selectedServer ?. computedUrl . trim ( ) } ${ tokenUrl . trim ( ) } ` ;
274+ } else {
275+ refreshUrl = `${ originUrl } /${ refreshUrl . replace ( / ^ \/ / , '' ) } ` ;
276+ }
269277 }
270278 if ( tokenUrl && ! isUrlAbsolute ( tokenUrl ) ) {
271- tokenUrl = `${ baseUrl } /${ tokenUrl . replace ( / ^ \/ / , '' ) } ` ;
279+ if ( this . selectedServer ?. computedUrl . trim ( ) . endsWith ( '/' ) && ! tokenUrl . trim ( ) . startsWith ( '/' ) ) {
280+ tokenUrl = `${ this . selectedServer ?. computedUrl . trim ( ) } ${ tokenUrl . trim ( ) } ` ;
281+ } else {
282+ tokenUrl = `${ originUrl } /${ tokenUrl . replace ( / ^ \/ / , '' ) } ` ;
283+ }
272284 }
273285 if ( authorizationUrl && ! isUrlAbsolute ( authorizationUrl ) ) {
274- authorizationUrl = `${ baseUrl } /${ authorizationUrl . replace ( / ^ \/ / , '' ) } ` ;
286+ if ( this . selectedServer ?. computedUrl . trim ( ) . endsWith ( '/' ) && ! authorizationUrl . trim ( ) . startsWith ( '/' ) ) {
287+ authorizationUrl = `${ this . selectedServer ?. computedUrl . trim ( ) } ${ authorizationUrl . trim ( ) } ` ;
288+ } else {
289+ authorizationUrl = `${ originUrl } /${ authorizationUrl . replace ( / ^ \/ / , '' ) } ` ;
290+ }
275291 }
276292 let flowNameDisplay ;
277293 if ( flowName === 'authorizationCode' ) {
0 commit comments