mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
Update browsermanager
This commit is contained in:
@@ -482,26 +482,33 @@ export class BrowserManager {
|
|||||||
if (!url) {
|
if (!url) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (typeof url !== 'string') {
|
||||||
|
throw new Error('Invalid URL: URL must be a string.');
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
try {
|
||||||
const parsedUrl = new URL(url as string);
|
const parsedUrl = new URL(url);
|
||||||
const urlHostname = parsedUrl.hostname;
|
const urlHostname = parsedUrl.hostname;
|
||||||
|
|
||||||
for (const domainPattern of allowedDomains) {
|
for (const domainPattern of allowedDomains) {
|
||||||
if (domainPattern.startsWith('*.')) {
|
if (domainPattern.startsWith('*.')) {
|
||||||
const baseDomain = domainPattern.substring(2);
|
const baseDomain = domainPattern.substring(2);
|
||||||
if (
|
if (
|
||||||
urlHostname === baseDomain ||
|
urlHostname === baseDomain ||
|
||||||
urlHostname.endsWith(`.${baseDomain}`)
|
urlHostname.endsWith(`.${baseDomain}`)
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (urlHostname === domainPattern) {
|
if (urlHostname === domainPattern) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
throw new Error('Invalid URL: Malformed URL string.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If none matched, then deny
|
// If none matched, then deny
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user