From 7c9a8bc630790b198e8d7acee2567ee71f3a04a1 Mon Sep 17 00:00:00 2001 From: stolen <2026438995@qq.com> Date: Sun, 7 Dec 2025 01:10:42 +0800 Subject: [PATCH] fix(index.ts): fix windows url encode --- src/filesystem/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/filesystem/index.ts b/src/filesystem/index.ts index 79a7b2fe4c..7c021316df 100644 --- a/src/filesystem/index.ts +++ b/src/filesystem/index.ts @@ -14,6 +14,7 @@ import { z } from "zod"; import { minimatch } from "minimatch"; import { normalizePath, expandHome } from './path-utils.js'; import { getValidRootDirectories } from './roots-utils.js'; +import { fileURLToPath } from "url"; import { // Function imports formatSize, @@ -700,6 +701,11 @@ server.server.setNotificationHandler(RootsListChangedNotificationSchema, async ( try { // Request the updated roots list from the client const response = await server.server.listRoots(); + for (const root of response.roots) { + // console.error("root", fileURLToPath(root.uri)); + // fix windows url encode file:///d%3A/work/ + root.uri = fileURLToPath(root.uri); + } if (response && 'roots' in response) { await updateAllowedDirectoriesFromRoots(response.roots); }