Skip to content

Commit

Permalink
chore: using URL object to set the api key
Browse files Browse the repository at this point in the history
  • Loading branch information
helloanoop authored Jan 17, 2025
1 parent d16a679 commit 525394b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/bruno-cli/src/runner/prepare-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ const prepareRequest = (item = {}, collection = {}) => {
}

if (collectionAuth.apikey?.placement === 'queryparams') {
if (axiosRequest.url) {
const prefix = (!axiosRequest.url.includes('?')) ? '?' : '&';
axiosRequest.url += `${prefix}${collectionAuth.apikey.key}=${collectionAuth.apikey.value}`;
if (axiosRequest.url && collectionAuth.apikey?.key) {
try {
const urlObj = new URL(request.url);
urlObj.searchParams.set(collectionAuth.apikey?.key, collectionAuth.apikey?.value);
axiosRequest.url = urlObj.toString();
} catch (error) {
console.error('Invalid URL:', request.url, error);
}
}
}
}
Expand Down

0 comments on commit 525394b

Please sign in to comment.