Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(repeater): validate proxy-domains and proxy-domains-bypass flags #624

Merged
merged 6 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading