Skip to content

Commit

Permalink
chore(repeater): validate proxy-domains and proxy-domains-bypass flags (
Browse files Browse the repository at this point in the history
#624)

Co-authored-by: Or Rubin <[email protected]>
  • Loading branch information
maksadbek and orubin authored Dec 3, 2024
1 parent c331d16 commit dc02da4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Commands/RunRepeater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ export class RunRepeater implements CommandModule {
describe:
'Space-separated list of domains that should be routed through the proxy. This option is only applicable when using the --proxy option',
coerce(arg: string[]): string[] {
if (arg[0] === undefined) {
return undefined;
}

// if values are passed from env variable, they are passed as a single string
if (arg.length === 1) {
if (arg[0].includes(' ')) {
Expand All @@ -161,6 +165,10 @@ export class RunRepeater implements CommandModule {
coerce(arg: string[]): string[] {
// if values are passed from env variable, they are passed as a single string
if (arg.length === 1) {
if (arg[0] === undefined) {
return undefined;
}

if (arg[0].includes(' ')) {
return arg[0].trim().split(' ');
}
Expand Down Expand Up @@ -193,6 +201,26 @@ export class RunRepeater implements CommandModule {
);
}

const proxyDomains = (args.proxyDomains as string[]) ?? [];
for (const domain of proxyDomains) {
if (domain.includes(',')) {
throw new Error(
`Option --proxy-domains has a wrong value.` +
`Please ensure that --proxy-domains option has space separated list of domain values`
);
}
}

const proxyDomainsBypass = (args.proxyDomainsBypass as string[]) ?? [];
for (const domain of proxyDomainsBypass) {
if (domain.includes(',')) {
throw new Error(
`Option --proxy-domain-bypass has wrong value.` +
`Please ensure that --proxy-domain-bypass option has space separated list of domain values`
);
}
}

return true;
})
.middleware((args: Arguments) => {
Expand Down

0 comments on commit dc02da4

Please sign in to comment.