Skip to content

Commit

Permalink
fix: properly set rest api hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
aarlaud committed Jul 3, 2024
1 parent a13a0f4 commit 8a6676d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lib/request/requestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ interface RequestsManagerParams {

function getRESTAPI(endpoint: string): string {
// e.g 'https://api.snyk.io/rest/'
const apiData = new URL(endpoint.replace('app.', ''));

return new URL(`${apiData.protocol}//api.${apiData.host}/rest`).toString();
const apiData = new URL(endpoint);
if (apiData.host.startsWith('api.')) {
console.warn(
`${apiData.host} seems invalid and should look like https://api.snyk.io or https://api.<REGION>.snyk.io.`,
);
}
return new URL(`${apiData.protocol}//${apiData.host}/rest`).toString();
}

const getConfig = (): { endpoint: string; token: string } => {
Expand Down

0 comments on commit 8a6676d

Please sign in to comment.