fix: normalize forward slash unc terminal paths (#3840)

This commit is contained in:
Jinwoo Hong 2026-05-30 14:58:35 -04:00 committed by GitHub
parent 6fc8b134b8
commit 441d13c78e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -13,6 +13,15 @@ describe('terminal path helpers', () => {
expect(toWorktreeRelativePath('C:\\repo\\src\\file.ts', 'C:\\repo')).toBe('src/file.ts')
})
it('keeps worktree-relative paths for forward-slash Windows UNC paths', () => {
expect(isPathInsideWorktree('//server/share/repo/src/file.ts', '\\\\server\\share\\repo')).toBe(
true
)
expect(
toWorktreeRelativePath('//server/share/repo/src/file.ts', '\\\\server\\share\\repo')
).toBe('src/file.ts')
})
describe('extractTerminalFileLinks bare-filename tokens', () => {
it('does not treat regular URL hosts as local file paths', () => {
expect(

View File

@ -36,7 +36,7 @@ export function normalizeAbsolutePath(pathValue: string): NormalizedAbsolutePath
}
}
const uncMatch = /^\\\\([^\\/]+)[\\/]+([^\\/]+)(?:[\\/]*(.*))?$/.exec(pathValue)
const uncMatch = /^(?:\\\\|\/\/)([^\\/]+)[\\/]+([^\\/]+)(?:[\\/]*(.*))?$/.exec(pathValue)
if (uncMatch) {
const server = uncMatch[1]
const share = uncMatch[2]