mirror of
https://github.com/stablyai/orca.git
synced 2026-09-25 00:02:35 +00:00
fix: allow dot-prefixed nested worktree paths (#3677)
This commit is contained in:
@@ -111,6 +111,12 @@ describe('ensurePathWithinWorkspace', () => {
|
||||
'Invalid worktree path'
|
||||
)
|
||||
})
|
||||
|
||||
it('allows workspace children whose names start with dot-dot text', () => {
|
||||
const result = ensurePathWithinWorkspace('/workspace/..repo/feature', '/workspace')
|
||||
|
||||
expect(result).toBe(resolve('/workspace/..repo/feature'))
|
||||
})
|
||||
})
|
||||
|
||||
describe('computeBranchName', () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { basename, join, resolve, relative, isAbsolute, posix, win32 } from 'path'
|
||||
import { basename, join, resolve, relative, isAbsolute, posix, sep, win32 } from 'path'
|
||||
import type { GitWorktreeInfo, Worktree, WorktreeMeta } from '../../shared/types'
|
||||
import { splitWorktreeId } from '../../shared/worktree-id'
|
||||
import { DEFAULT_WORKSPACE_STATUS_ID } from '../../shared/workspace-statuses'
|
||||
@@ -57,7 +57,7 @@ export function ensurePathWithinWorkspace(targetPath: string, workspaceDir: stri
|
||||
const resolvedTargetPath = resolve(targetPath)
|
||||
const rel = relative(resolvedWorkspaceDir, resolvedTargetPath)
|
||||
|
||||
if (isAbsolute(rel) || rel.startsWith('..')) {
|
||||
if (isAbsolute(rel) || rel === '..' || rel.startsWith(`..${sep}`)) {
|
||||
throw new Error('Invalid worktree path')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user