@@ -7,6 +7,7 @@ import * as packageCache from '../cache/package';
77import { parseJson } from '../common' ;
88import * as hostRules from '../host-rules' ;
99import { Http } from '../http' ;
10+ import { ensureTrailingSlash , joinUrlParts } from '../url' ;
1011import { MERGE_CONFIDENCE } from './common' ;
1112import type { MergeConfidence } from './types' ;
1213
@@ -164,7 +165,14 @@ async function queryApi(
164165 }
165166
166167 const escapedPackageName = packageName . replace ( '/' , '%2f' ) ;
167- const url = `${ apiBaseUrl } api/mc/json/${ datasource } /${ escapedPackageName } /${ currentVersion } /${ newVersion } ` ;
168+ const url = joinUrlParts (
169+ apiBaseUrl ,
170+ 'api/mc/json' ,
171+ datasource ,
172+ escapedPackageName ,
173+ currentVersion ,
174+ newVersion ,
175+ ) ;
168176 const cacheKey = `${ token } :${ url } ` ;
169177 const cachedResult = await packageCache . get ( hostType , cacheKey ) ;
170178
@@ -217,7 +225,7 @@ export async function initMergeConfidence(): Promise<void> {
217225 return ;
218226 }
219227
220- const url = ` ${ apiBaseUrl } api/mc/availability` ;
228+ const url = joinUrlParts ( apiBaseUrl , ' api/mc/availability' ) ;
221229 try {
222230 await http . get ( url ) ;
223231 } catch ( err ) {
@@ -246,7 +254,7 @@ function getApiBaseUrl(): string {
246254 { baseUrl : parsedBaseUrl } ,
247255 'using merge confidence API base found in environment variables' ,
248256 ) ;
249- return parsedBaseUrl ;
257+ return ensureTrailingSlash ( parsedBaseUrl ) ;
250258 } catch ( err ) {
251259 logger . warn (
252260 { err, baseFromEnv } ,
0 commit comments