mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
Check domain
This commit is contained in:
@@ -254,6 +254,21 @@ describe('BrowserManager', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw error when invalid domain is configured in allowedDomains', async () => {
|
||||
const invalidConfig = makeFakeConfig({
|
||||
agents: {
|
||||
browser: {
|
||||
allowedDomains: ['invalid domain!'],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const manager = new BrowserManager(invalidConfig);
|
||||
await expect(manager.ensureConnection()).rejects.toThrow(
|
||||
'Invalid domain in allowedDomains: invalid domain!',
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass headless flag when configured', async () => {
|
||||
const headlessConfig = makeFakeConfig({
|
||||
agents: {
|
||||
|
||||
@@ -292,7 +292,12 @@ export class BrowserManager {
|
||||
browserConfig.customConfig.allowedDomains.length > 0
|
||||
) {
|
||||
const exclusionRules = browserConfig.customConfig.allowedDomains
|
||||
.map((domain) => `EXCLUDE ${domain}`)
|
||||
.map((domain) => {
|
||||
if (!/^(\*\.)?([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/.test(domain)) {
|
||||
throw new Error(`Invalid domain in allowedDomains: ${domain}`);
|
||||
}
|
||||
return `EXCLUDE ${domain}`;
|
||||
})
|
||||
.join(', ');
|
||||
mcpArgs.push(
|
||||
`--chromeArg="--host-rules=MAP * 127.0.0.1, ${exclusionRules}, EXCLUDE 127.0.0.1"`,
|
||||
|
||||
Reference in New Issue
Block a user