Skip to content

Commit a3aa8c6

Browse files
committed
fix(files): a bare files/ prefix is not a path
1 parent 24d5fa2 commit a3aa8c6

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎apps/sim/lib/vfs/path.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ export class VfsPathError extends Error {
1010
}
1111
}
1212

13-
/** A `files/…` workspace-file VFS path. File ids are drawn from `[A-Za-z0-9_-]`, so no id is one. */
13+
/**
14+
* A `files/…` workspace-file VFS path naming something under the prefix. File ids are drawn from
15+
* `[A-Za-z0-9_-]`, so no id is one.
16+
*/
1417
export function isWorkspaceFileVfsPath(reference: string): boolean {
15-
return reference.startsWith('files/')
18+
return reference.startsWith('files/') && reference.length > 'files/'.length
1619
}
1720

1821
/**

‎apps/sim/lib/workspace-files/__integration__/file-path-references.integration.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ describe('single-file operations addressed by VFS path', () => {
150150
code: 'not_found',
151151
})
152152
await expect(describeFile('files/Docs')).rejects.toMatchObject({ code: 'not_found' })
153+
await expect(describeFile('files/')).rejects.toMatchObject({ code: 'not_found' })
153154
await expect(describeFile('files/only-here.csv')).rejects.toMatchObject({
154155
code: 'not_found',
155156
})

0 commit comments

Comments
 (0)