From 547a573e990e6672da0e7764197dc37db3a67710 Mon Sep 17 00:00:00 2001 From: Matt Mulligan Date: Mon, 20 Jun 2022 22:47:23 -0400 Subject: [PATCH] Added check for if key is provided in request params Signed-off-by: Matt Mulligan --- .../search/StackOverflowQuestionsCollatorFactory.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/stack-overflow-backend/src/search/StackOverflowQuestionsCollatorFactory.ts b/plugins/stack-overflow-backend/src/search/StackOverflowQuestionsCollatorFactory.ts index 15bf34a71c..45261ce546 100644 --- a/plugins/stack-overflow-backend/src/search/StackOverflowQuestionsCollatorFactory.ts +++ b/plugins/stack-overflow-backend/src/search/StackOverflowQuestionsCollatorFactory.ts @@ -71,9 +71,9 @@ export class StackOverflowQuestionsCollatorFactory private constructor(options: StackOverflowQuestionsCollatorFactoryOptions) { this.baseUrl = options.baseUrl; + this.apiKey = options.apiKey; this.requestParams = options.requestParams; this.logger = options.logger; - this.apiKey = options.apiKey; } static fromConfig( @@ -102,7 +102,16 @@ export class StackOverflowQuestionsCollatorFactory ); } - this.logger.warn(`${JSON.stringify(this.requestParams)}`); + try { + if (Object.keys(this.requestParams).indexOf('key') >= 0) { + this.logger.warn( + 'The API Key should be passed as a seperate param to bypass encoding', + ); + delete this.requestParams.key; + } + } catch (e) { + this.logger.error(`Caught ${e}`); + } const params = qs.stringify(this.requestParams, { arrayFormat: 'comma',