Skip to content

Commit

Permalink
feat: convert apikey query param to header
Browse files Browse the repository at this point in the history
  • Loading branch information
akira28 committed Jul 25, 2024
1 parent fcbee12 commit 3c201fb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ util = {
location = `${POSTMAN_API_URL}/${POSTMAN_API_PATH_MAP[type]}/${location}`;
headers[API_KEY_HEADER] = postmanApiKey;
}
// if location contains the apikey query param, remove it and add it to headers
else if (location.includes('apikey=')) {
try {
// eslint-disable-next-line one-var
var url = new URL(location),
apiKey = url.searchParams.get('apikey');

url.searchParams.delete('apikey');
headers[API_KEY_HEADER] = apiKey;
location = url.toString();
}
catch (e) {
// if not a valid url, ignore
}
}

return (/^https?:\/\/.*/).test(location) ?
// Load from URL
Expand Down

0 comments on commit 3c201fb

Please sign in to comment.