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
  • Loading branch information
maksadbek committed Dec 2, 2024
1 parent 76b0bc3 commit 8b80d9a
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 wrong value.` +
`Please ensure that --proxy-domains option has spaced separate 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 spaced separate list of domain values`
);
}
}

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

0 comments on commit 8b80d9a

Please sign in to comment.