Skip to content

Commit bb9daa8

Browse files
devartifexCopilot
andcommitted
fix: handle Windows path separators in attachment and session path display
Use regex split /[/\\]/ instead of split('/') to handle both forward and backslash separators. Affects ChatMessage attachment URL extraction and session path display in SessionPreview and SessionsSheet components. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 21e0ab7 commit bb9daa8

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/lib/components/chat/ChatMessage.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
const a = att as { type: 'file'; path: string; name: string };
3535
const ext = a.name.split('.').pop()?.toLowerCase() ?? '';
3636
const isImage = IMAGE_EXTENSIONS.has(ext);
37-
// Extract uploadId and filename from path: /tmp/copilot-uploads/{uploadId}/{filename}
38-
const parts = a.path.split('/');
37+
// Extract uploadId and filename from path (handles both / and \ separators)
38+
const parts = a.path.split(/[/\\]/);
3939
const filename = parts[parts.length - 1];
4040
const uploadId = parts[parts.length - 2];
4141
const url = `/api/upload/files/${encodeURIComponent(uploadId)}/${encodeURIComponent(filename)}`;

src/lib/components/sessions/SessionPreview.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
2424
function formatPath(cwd: string | undefined): string {
2525
if (!cwd) return '';
26-
const parts = cwd.split('/').filter(Boolean);
26+
const parts = cwd.split(/[/\\]/).filter(Boolean);
2727
return parts.length > 3 ? `…/${parts.slice(-3).join('/')}` : cwd;
2828
}
2929
</script>

src/lib/components/sessions/SessionsSheet.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
function formatPath(cwd: string | undefined): string {
141141
if (!cwd) return '';
142142
// Show last 2 path segments
143-
const parts = cwd.split('/').filter(Boolean);
143+
const parts = cwd.split(/[/\\]/).filter(Boolean);
144144
return parts.length > 2 ? `…/${parts.slice(-2).join('/')}` : cwd;
145145
}
146146
</script>

0 commit comments

Comments
 (0)