Skip to content

Commit 4d0c60a

Browse files
fix: not merged multiple mtls options in the respect (#2431)
1 parent 4c8563b commit 4d0c60a

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

.changeset/twelve-toys-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@redocly/cli": patch
3+
---
4+
5+
Fixed an issue where multiple `--mtls` options in the Respect command did not merge as expected.

packages/cli/src/commands/respect/mtls/validate-mtls-command-option.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
11
import type { MtlsConfig } from '../index.js';
22

3-
export function validateMtlsCommandOption(value: string): MtlsConfig | undefined {
4-
if (!value) return undefined;
3+
export function validateMtlsCommandOption(value: string | string[]): MtlsConfig | undefined {
4+
if (Array.isArray(value)) {
5+
const merged: MtlsConfig = {};
56

7+
for (const item of value) {
8+
if (!item) continue;
9+
if (typeof item === 'string') {
10+
const parsed = parseAndValidateMtlsConfig(item);
11+
Object.assign(merged, parsed);
12+
}
13+
}
14+
15+
return Object.keys(merged).length > 0 ? merged : undefined;
16+
}
17+
18+
if (!value || typeof value !== 'string') {
19+
return undefined;
20+
}
21+
22+
return parseAndValidateMtlsConfig(value);
23+
}
24+
25+
function parseAndValidateMtlsConfig(value: string): MtlsConfig {
626
try {
727
const parsed = JSON.parse(value);
828

packages/cli/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ yargs(hideBin(process.argv))
735735
describe:
736736
'Per-domain mutual TLS certificates configuration as JSON. Format: {"<domain>": {"clientCert": "<path>", "clientKey": "<path>", "caCert": "<path>"}}',
737737
type: 'string',
738+
array: true,
738739
coerce: validateMtlsCommandOption,
739740
},
740741
severity: {

0 commit comments

Comments
 (0)