From 0052061a72421903b14bbe0933cb7db83ccb2b9b Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Sun, 16 Aug 2026 22:28:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(html):=20UNC=20=E6=A0=87=E8=AE=B0=E4=BF=A1?= =?UTF-8?q?=E5=8F=B7=E7=BA=B3=E5=85=A5=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=9C=AC=E8=BA=AB=EF=BC=88=E5=9B=9E=E5=BA=94=20Codex=20P2=20re?= =?UTF-8?q?view=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cwd 未水合或为正斜杠形式时,仅凭 scope.cwd 会漏掉反斜杠 UNC 路径的 '//' 标记,win32 上预览被 isWithin 拒绝(403)。htmlUrl 现在同时以 isWindowsStylePath(path) 判定:明确的反斜杠 UNC 路径始终保留标记; '//' 正斜杠路径仍只由 cwd 形态决定(POSIX 不受影响)。 --- src/client/api.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/client/api.ts b/src/client/api.ts index 6a56bff..b1e72d1 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -215,10 +215,15 @@ function fileUrl(scope: SessionScope, path: string, download: boolean): string { /** * Absolute URL of the HTML preview route (see html-route.ts): the path is * fully encoded so the previewed page's relative assets resolve back into - * the same route with the session scope intact. The session cwd's shape - * supplies the platform guard for the UNC marker (the browser OS may differ - * from the host OS, so no client-side platform detection is used). + * the same route with the session scope intact. The platform guard for the + * UNC marker comes from the session cwd's shape (the browser OS may differ + * from the host OS, so no client-side platform detection is used), extended + * by the file path itself: an unambiguous backslash UNC path keeps its '//' + * marker even while the cwd is still hydrating or arrives in forward-slash + * form. Forward-slash `//` paths stay ambiguous without a Windows-style cwd, + * so they are deliberately NOT marked on their own — a POSIX session keeps + * them as ordinary absolute paths. */ export function htmlUrl(scope: SessionScope, path: string): string { - return encodeHtmlUrl(scope.sessionId, path, isWindowsStylePath(scope.cwd ?? '')) + return encodeHtmlUrl(scope.sessionId, path, isWindowsStylePath(scope.cwd ?? '') || isWindowsStylePath(path)) }