mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 22:54:24 +01:00
fix: sanitize names before enabling/disabling extensions in Settings V2 (#2040)
This commit is contained in:
@@ -140,6 +140,8 @@ export async function addToAgent(
|
|||||||
extension.cmd = await replaceWithShims(extension.cmd);
|
extension.cmd = await replaceWithShims(extension.cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension.name = sanitizeName(extension.name);
|
||||||
|
|
||||||
return await extensionApiCall('/extensions/add', extension, options);
|
return await extensionApiCall('/extensions/add', extension, options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Check if this is a 428 error and make the message more descriptive
|
// Check if this is a 428 error and make the message more descriptive
|
||||||
@@ -162,9 +164,13 @@ export async function removeFromAgent(
|
|||||||
options: ToastServiceOptions = {}
|
options: ToastServiceOptions = {}
|
||||||
): Promise<Response> {
|
): Promise<Response> {
|
||||||
try {
|
try {
|
||||||
return await extensionApiCall('/extensions/remove', name, options);
|
return await extensionApiCall('/extensions/remove', sanitizeName(name), options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to remove extension ${name} from agent:`, error);
|
console.error(`Failed to remove extension ${name} from agent:`, error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sanitizeName(name: string) {
|
||||||
|
return name.toLowerCase().replace(/-/g, '').replace(/_/g, '').replace(/\s/g, '');
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user