Skip to content

Commit 87fed0a

Browse files
committed
Prevent double forward slash in queryApi
1 parent 1f68a93 commit 87fed0a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils/api.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ export function getDefaultApiBaseUrl(): string | undefined {
7777
}
7878

7979
export async function queryApi(path: string, apiToken: string) {
80-
const API_V0_URL = getDefaultApiBaseUrl()
81-
return await fetch(`${API_V0_URL}/${path}`, {
80+
const API_V0_URL = getDefaultApiBaseUrl() || ''
81+
if (!API_V0_URL) {
82+
logger.warn('API endpoint is not set and default was empty. Request is likely to fail.')
83+
}
84+
return await fetch(`${API_V0_URL}${API_V0_URL.endsWith('/')?'':'/'}${path}`, {
8285
method: 'GET',
8386
headers: {
8487
Authorization: `Basic ${btoa(`${apiToken}:`)}`

0 commit comments

Comments
 (0)