Skip to content

Commit

Permalink
handle case where options are combined
Browse files Browse the repository at this point in the history
  • Loading branch information
sserrata committed Dec 16, 2024
1 parent 1f875bc commit 77c847d
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@ function CodeSnippets({ postman, codeSamples }: Props) {

const auth = useTypedSelector((state: any) => state.auth);
const clonedAuth = cloneDeep(auth);
console.log(clonedAuth);
let placeholder: string;

function cleanCredentials(obj: any) {
for (const key in obj) {
if (typeof obj[key] === "object" && obj[key] !== null) {
// use name as placeholder if exists
placeholder = clonedAuth?.options?.[key]?.[0]?.name;
const comboAuthId = Object.keys(obj).join(" and ");
const authOptions =
clonedAuth?.options?.[key] ?? clonedAuth?.options?.[comboAuthId];
placeholder = authOptions?.[0]?.name;
obj[key] = cleanCredentials(obj[key]);
} else {
obj[key] = `<${placeholder ?? key}>`;
Expand Down

0 comments on commit 77c847d

Please sign in to comment.