Skip to content

Commit 11c29b2

Browse files
committed
refactor: remove redundant validatePath calls
1 parent 176eb69 commit 11c29b2

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

src/McpContext.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,6 @@ export class McpContext implements Context {
830830
}
831831

832832
async installExtension(extensionPath: string): Promise<string> {
833-
await this.validatePath(extensionPath);
834833
const id = await this.browser.installExtension(extensionPath);
835834
return id;
836835
}
@@ -861,37 +860,32 @@ export class McpContext implements Context {
861860
async getHeapSnapshotAggregates(
862861
filePath: string,
863862
): Promise<Record<string, AggregatedInfoWithId>> {
864-
await this.validatePath(filePath);
865863
return await this.#heapSnapshotManager.getAggregates(filePath);
866864
}
867865

868866
async getHeapSnapshotStats(
869867
filePath: string,
870868
): Promise<DevTools.HeapSnapshotModel.HeapSnapshotModel.Statistics> {
871-
await this.validatePath(filePath);
872869
return await this.#heapSnapshotManager.getStats(filePath);
873870
}
874871

875872
async getHeapSnapshotStaticData(
876873
filePath: string,
877874
): Promise<DevTools.HeapSnapshotModel.HeapSnapshotModel.StaticData | null> {
878-
await this.validatePath(filePath);
879875
return await this.#heapSnapshotManager.getStaticData(filePath);
880876
}
881877

882878
async getHeapSnapshotNodesById(
883879
filePath: string,
884880
id: number,
885881
): Promise<DevTools.HeapSnapshotModel.HeapSnapshotModel.ItemsRange> {
886-
await this.validatePath(filePath);
887882
return await this.#heapSnapshotManager.getNodesById(filePath, id);
888883
}
889884

890885
async getHeapSnapshotRetainers(
891886
filePath: string,
892887
nodeId: number,
893888
): Promise<DevTools.HeapSnapshotModel.HeapSnapshotModel.ItemsRange> {
894-
await this.validatePath(filePath);
895889
return await this.#heapSnapshotManager.getRetainers(filePath, nodeId);
896890
}
897891
}

src/tools/extensions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const installExtension = defineTool({
2424
blockedByDialog: false,
2525
handler: async (request, response, context) => {
2626
const {path} = request.params;
27+
await context.validatePath(path);
2728
const id = await context.installExtension(path);
2829
response.appendResponseLine(`Extension installed. Id: ${id}`);
2930
},
@@ -79,6 +80,7 @@ export const reloadExtension = defineTool({
7980
if (!extension) {
8081
throw new Error(`Extension with ID ${id} not found.`);
8182
}
83+
await context.validatePath(extension.path);
8284
await context.installExtension(extension.path);
8385
response.appendResponseLine('Extension reloaded.');
8486
},

0 commit comments

Comments
 (0)